I have two tables - a subset of columns in table 1 have names which are also rows entries (in a column, say column 7) in table 2.
table 2 rows are sorted in a desired (ascending) order.
I would like to reorder only those columns in table 1 which have column names occurring in table 2 in the order they are sorted (in column 7) in table 2.
How to achieve this via JSL?
Here is an example of one way to handle the question
names default to here(1);
table1 =
// Open Data Table: semiconductor capability.jmp
// → Data Table( "semiconductor capability" )
Open( "$SAMPLE_DATA/Big Class.jmp" );
table2 = New Table("Table 2",
New Column("Sort Order", character,
Values({"height","weight","sex"})
)
);
For( i = N Rows( table2 ), i >= 1, i--,
Try(
table1 << go to( Column( table2, 1 )[i] );
table1 << Move Selected Columns( To first );
)
);
Few questions:
@jthi All valid questions. I will try to answer them below.
@jthi Thanks
Here is an example of one way to handle the question
names default to here(1);
table1 =
// Open Data Table: semiconductor capability.jmp
// → Data Table( "semiconductor capability" )
Open( "$SAMPLE_DATA/Big Class.jmp" );
table2 = New Table("Table 2",
New Column("Sort Order", character,
Values({"height","weight","sex"})
)
);
For( i = N Rows( table2 ), i >= 1, i--,
Try(
table1 << go to( Column( table2, 1 )[i] );
table1 << Move Selected Columns( To first );
)
);