- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Stacking Columns in Script
I have a couple of questions about stacking data columns in a script. When I do it manually, I get the following script from JMP:
Data Table( "Untitled 11" ) << Stack(
columns(
:Name( "EFL 20508-17DT_CG_100ms" ),
:Name( "FFL 20508-17DT_CG_100ms" ),
:Name( "EFL 20508-18DT_CG_100ms" ),
:Name( "FFL 20508-18DT_CG_100ms" ),
:Name( "EFL 20508-19DT_NOCG_2" ),
:Name( "FFL 20508-19DT_NOCG_2" )
),
Source Label Column( "Label" ),
Stacked Data Column( "Data" ),
Number of Series( 2 )
)
In my script, I have a list variable (MyList1) containing the column names, and I would like to stack those columns using "Multiple Series Stack" to create a new table. Also, for "Number of Series" I would like to include NItems(MyList2). Can someone help me with the syntax?
I think this should work:
StackDT = SplitDT << Stack( Columns( MyList1 ),
Source Label Column( "Source" ),
Stacked Data Column( "Data" ),
Number of Series( NItems( MyList2 ) )
)
);
but it gives me "Column not found in access or evaluation of 'Bad Argument' " in the log.
Data Table( "Untitled 11" ) << Stack(
columns(
:Name( "EFL 20508-17DT_CG_100ms" ),
:Name( "FFL 20508-17DT_CG_100ms" ),
:Name( "EFL 20508-18DT_CG_100ms" ),
:Name( "FFL 20508-18DT_CG_100ms" ),
:Name( "EFL 20508-19DT_NOCG_2" ),
:Name( "FFL 20508-19DT_NOCG_2" )
),
Source Label Column( "Label" ),
Stacked Data Column( "Data" ),
Number of Series( 2 )
)
In my script, I have a list variable (MyList1) containing the column names, and I would like to stack those columns using "Multiple Series Stack" to create a new table. Also, for "Number of Series" I would like to include NItems(MyList2). Can someone help me with the syntax?
I think this should work:
StackDT = SplitDT << Stack( Columns( MyList1 ),
Source Label Column( "Source" ),
Stacked Data Column( "Data" ),
Number of Series( NItems( MyList2 ) )
)
);
but it gives me "Column not found in access or evaluation of 'Bad Argument' " in the log.
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Stacking Columns in Script
I think
Columns(eval(MyList1))
should work.
You might want to call tech support and report it as a bug, or suggestion.
Columns(eval(MyList1))
should work.
You might want to call tech support and report it as a bug, or suggestion.
10 REPLIES 10
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Stacking Columns in Script
I think
Columns(eval(MyList1))
should work.
You might want to call tech support and report it as a bug, or suggestion.
Columns(eval(MyList1))
should work.
You might want to call tech support and report it as a bug, or suggestion.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Stacking Columns in Script
Yes. Evaluating the list does make it work. The list used for "Number of Series" also has to be evaluated.
Thanks for the reply.
Thanks for the reply.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Stacking Columns in Script
I have a related question about stacking columns. I have been given an Excel spreadsheet that I need to turn into something useful. The spreadsheet looks like this:
style="font-family: Courier New; font-weight: bold; text-decoration: underline;">IDNo Ctry
Sub Sub
Date Ctry Sub Sub
Date Ctry Sub Sub Date
style="font-family: Courier New;">
a123 US
N Can
Y 4/1/2010 Braz
Y 3/15/2009
style="font-family: Courier New;">
b567 US
Y 5/1/2009 Can
N
Braz N
style="font-family: Courier New;">
c392 US
Y 6/1/2008 Can
Y 3/2/2001 Braz
Y 12/15/2008
etc.
I need to stack the results so they look like this:
style="font-family: Courier New; font-weight: bold; text-decoration: underline;">IDNo
Ctry Sub Sub Date
style="font-family: Courier New;">
a123
US N
style="font-family: Courier New;">
b567
US Y
5/1/2009
style="font-family: Courier New;">
c392
US Y
6/1/2008
style="font-family: Courier New;">
a123
Can
Y 4/1/2010
style="font-family: Courier New;">
b567
Can N
style="font-family: Courier New;">
c392
Can
Y 3/2/2001
style="font-family: Courier New;">
a123
Braz Y 3-15-2009
style="font-family: Courier New;">
b567
Braz N
style="font-family: Courier New;">
c392
Braz Y 12/15/2008
In the real table there are about 20 countries going across. Is this something that the STACK command can handle? I.e. instead of just stacking one column, I need to stack three columns at once.
Thanks,
Peter
style="font-family: Courier New; font-weight: bold; text-decoration: underline;">IDNo Ctry
Sub Sub
Date Ctry Sub Sub
Date Ctry Sub Sub Date
style="font-family: Courier New;">
a123 US
N Can
Y 4/1/2010 Braz
Y 3/15/2009
style="font-family: Courier New;">
b567 US
Y 5/1/2009 Can
N
Braz N
style="font-family: Courier New;">
c392 US
Y 6/1/2008 Can
Y 3/2/2001 Braz
Y 12/15/2008
etc.
I need to stack the results so they look like this:
style="font-family: Courier New; font-weight: bold; text-decoration: underline;">IDNo
Ctry Sub Sub Date
style="font-family: Courier New;">
a123
US N
style="font-family: Courier New;">
b567
US Y
5/1/2009
style="font-family: Courier New;">
c392
US Y
6/1/2008
style="font-family: Courier New;">
a123
Can
Y 4/1/2010
style="font-family: Courier New;">
b567
Can N
style="font-family: Courier New;">
c392
Can
Y 3/2/2001
style="font-family: Courier New;">
a123
Braz Y 3-15-2009
style="font-family: Courier New;">
b567
Braz N
style="font-family: Courier New;">
c392
Braz Y 12/15/2008
In the real table there are about 20 countries going across. Is this something that the STACK command can handle? I.e. instead of just stacking one column, I need to stack three columns at once.
Thanks,
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Stacking Columns in Script
Yes. Look up Multiple Series Stack in the docs. There seems to be a minor bug which results in stacked date columns in multiple series stacking not being formatted as dates so you'll have to apply that format after stacking. Single column stacking of dates does maintain date format. You will also have to clean up some extra columns that result from the stacking.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Stacking Columns in Script
Thanks that worked perfectly! This will save us a tremendous amount of time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Stacking Columns in Script
Maybe I can append a further question:
I want to stack several columns, column wise. This is easy going the menu way - simply by unchecking 'Stack by Row'. But I have not found an equivalent option on the stack scripting command.
Is it intended to go the cumbersome way to first create a transposed intermediate table, and then applying the stacking on that one?
Regards,
esa
I want to stack several columns, column wise. This is easy going the menu way - simply by unchecking 'Stack by Row'. But I have not found an equivalent option on the stack scripting command.
Is it intended to go the cumbersome way to first create a transposed intermediate table, and then applying the stacking on that one?
Regards,
esa
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Stacking Columns in Script
You simply add "Stack By Row(0)" to your Stack message. Here's an example:
<--
Data Table( "Solubility" ) << Stack(
columns(
:Name( "1-Octanol" ),
:Ether,
:Chloroform,
:Benzene,
:Carbon Tetrachloride,
:Hexane
),
Source Label Column( "Label" ),
Stacked Data Column( "Data" ),
Stack By Row( 0 )
)
-->
<--
Data Table( "Solubility" ) << Stack(
columns(
:Name( "1-Octanol" ),
:Ether,
:Chloroform,
:Benzene,
:Carbon Tetrachloride,
:Hexane
),
Source Label Column( "Label" ),
Stacked Data Column( "Data" ),
Stack By Row( 0 )
)
-->
-Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Stacking Columns in Script
Glad to here that. I expected something like this, but was unable to retrieve this information from anywhere within the documentation.
Thank you.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Stacking Columns in Script
I'm glad that will help.
In a case like this, it's easiest to perform the action interactively by clicking and then examine the "Source" script in the resulting table.
Jeff
In a case like this, it's easiest to perform the action interactively by clicking and then examine the "Source" script in the resulting table.
Jeff
-Jeff