BookmarkSubscribe
Choose Language Hide Translation Bar
natalie_
Community Trekker

Using a for loop to reference different columns?

Hi All,

I would like "transpose" a column from data table to another data table.  In the first data table, I have my data in a column, and I would like to organize it horizontally in the other data table starting in the second column (named 0V).  I am using a for loop to reference the different column names, but it not filling the row with data.

for(j=1, j<=66, j++,

       id = dtDevice:Id_A;

       name = char((i-1)*10)||"V";

       dtSummary:name[row]=id;

  );

Any suggestions?

0 Kudos
1 ACCEPTED SOLUTION

Accepted Solutions
pmroz
Super User

Re: Using a for loop to reference different columns?

You are using a variable row without assigning it to anything.  I wouldn't use j as a looping variable - it's a function in JMP.  Finally you need to add rows as shown below.

for(k=1, k<=66, j++,

        id = dtDevice:Id_A;

       name = char((k-1)*10)||"V";

       dtSummary << add rows(1);

       dtSummary:name=id;

  );

2 REPLIES 2
pmroz
Super User

Re: Using a for loop to reference different columns?

You are using a variable row without assigning it to anything.  I wouldn't use j as a looping variable - it's a function in JMP.  Finally you need to add rows as shown below.

for(k=1, k<=66, j++,

        id = dtDevice:Id_A;

       name = char((k-1)*10)||"V";

       dtSummary << add rows(1);

       dtSummary:name=id;

  );

natalie_
Community Trekker

Re: Using a for loop to reference different columns?

I had the row assigned before the loop and I added rows, too.  The problem was that I was using j not k.  I had no idea it was a function!  Thank you so much.

0 Kudos