cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
jvillaumie
Level III

JSL: stacking a single Group of columns (as opposed to the many individual columns that make up the Group) ?

Hello,

I need to stack columns which have a certain string in their column name, so I wrote a script to iterate through all the columns to see if their name has the sought string, then make a Group with all the columns that have that string (see script below. the columns are pushed to the end of the table to make them easier to group).

I then want to stack the group of columns, which is straightforward when doing it manually (selecting the Group populates the Stack window with the name of all the columns in the group). I cannot however figure out how to script the Stack() command to use the Group as an argument.

Is a Group a valid argument for the Stack() function, and if so what is the JSL syntax?

If not valid, what are the other option to stack a (variable) number of columns?

dt = current data table ();

col_name_list = (dt << Get Column Names());

n_dissolution_columns = 0;

for (var_column_number= N Items (col_name_list), var_column_number >= 1, var_column_number --,

     current_column_name= uppercase(char(col_name_list[var_column_number]));

         

     if( munger((current_column_name),1,"DISSOLUTION") > 0,

     n_dissolution_columns= n_dissolution_columns +1;

           column(var_column_number)<< Set Selected(1);

      dt<< Move Selected Columns(To Last);

     );

);   

dt << Group Columns("Dissolution columns group", column(N Items (col_name_list)+1 - n_dissolution_columns), n_dissolution_columns);

1 ACCEPTED SOLUTION

Accepted Solutions
jvillaumie
Level III

Re: JSL: stacking a single Group of columns (as opposed to the many individual columns that make up the Group) ?

I found the answer in a different post about transposing a group of column (How does one use a group of columns in a transpose data statement). the way to do it is to use << get column group("group name"):

dt << Stack(

columns( dt << get column group( "Dissolution columns group" ) ),

Output Table( "Stacked using the Group name as argument" )

);


View solution in original post

1 REPLY 1
jvillaumie
Level III

Re: JSL: stacking a single Group of columns (as opposed to the many individual columns that make up the Group) ?

I found the answer in a different post about transposing a group of column (How does one use a group of columns in a transpose data statement). the way to do it is to use << get column group("group name"):

dt << Stack(

columns( dt << get column group( "Dissolution columns group" ) ),

Output Table( "Stacked using the Group name as argument" )

);