Subscribe Bookmark RSS Feed

Using a for loop to reference different columns?

natalie_

Community Trekker

Joined:

Jan 6, 2016

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

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
Solution

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

Joined:

Jan 6, 2016

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.