Choose Language Hide Translation Bar
Highlighted
axcelenator1
Level III

Stack a group of columns

Hello, I have some table with a group of columns. I want to stack the group with a script how can I do that?

dt = open("C:\Users\My.jmp");

s_list = {h1, j2, k3};//List


//Generate XX new columns by Text to Cols ADD-In
For( i = 1, i<= Length(s_list), i++, 
	    dt << New Column  ("My_New_Coloumn_" || s_list[i],  
		Numeric,
		Continuous,
		Formula(
				Num(Word( i, As Column(Column("CPU" )), "|" ))//CPU is a column that contains for example: 5|5|7
			    ),
		),
		
		
);
dt << Group Columns(:My_New_Column_h1,3);

Here I try to stack the aboved Group

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
jerry_cooper
Staff (Retired)

Re: Stack a group of columns

Hi @axcelenator1,

Does the example below help for what you are trying to do?

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Blood Pressure.jmp" );
group = dt << Group Columns( BP 8M, 9 );

dt << Stack(
	columns(
		dt << Get Column Group( group );
	),
	Source Label Column( "Label" ),
	Stacked Data Column( "Data" )
)

View solution in original post

5 REPLIES 5
Highlighted
txnelson
Super User

Re: Stack a group of columns

Interactively run the Stack Platform on your 3 columns

     Tables==>Stack

and then in the new table created, Edit the source for the table, and you will see the JSL necessary to stack the columns the way you want.

Jim
Highlighted
axcelenator1
Level III

Re: Stack a group of columns

Hi,
actually my s_list is a randomal list bigger than 3 items that is changing all the time.
The stack JSL gives the new columns names that were generated and concatenated inside the For Loop. I need to find a solution to something like generating a List and put it inside the Columns in the Stack function but I can't get it....


Highlighted
txnelson
Super User

Re: Stack a group of columns

Apparently I am confused on what you actually want to accomplish. In JMP Stacking typically implies that one is stacking two or more columns on top of each other. Grouping of Columns makes organizational groups of columns, that allow for the easy handling of them for use with the various platforms.
Could you provide more detail on what you want your data table, and any new columns you are creating to look like?
Jim
Highlighted
axcelenator1
Level III

Re: Stack a group of columns

I have something like 19 columns that are stacked together. The names of the columns are generated in the aboved loop that is posted.
I want to make an auto script that will use the column names generated above and use it inside the Stack() function.

Stack(Columns("***Here I want the auto script to generate the columns names***")...........
Highlighted
jerry_cooper
Staff (Retired)

Re: Stack a group of columns

Hi @axcelenator1,

Does the example below help for what you are trying to do?

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Blood Pressure.jmp" );
group = dt << Group Columns( BP 8M, 9 );

dt << Stack(
	columns(
		dt << Get Column Group( group );
	),
	Source Label Column( "Label" ),
	Stacked Data Column( "Data" )
)

View solution in original post

Article Labels

    There are no labels assigned to this post.