<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic JMP script to Stack from column 2-infinity from a weekly updating Excel table in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JMP-script-to-Stack-from-column-2-infinity-from-a-weekly/m-p/449797#M69665</link>
    <description>&lt;P&gt;I have an Excel table that I am manually updating on a weekly basis. Next, I open this table in JMP and Stack every column from column 2 onward. With every weekly update, I add more columns to the initial table. I recently took an Intro to JMP Scripting class and I'm looking to automate this process a bit instead of re-Stacking it from scratch every time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what the table looks like in JMP before performing the Stack:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JMPexample.jpg" style="width: 523px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/38807i34C273087921D8DB/image-dimensions/523x238?v=v2" width="523" height="238" role="button" title="JMPexample.jpg" alt="JMPexample.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know how to import the Excel table into JMP via a script like so:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Open(
	"Drive:\Folder\File.xlsx",
	Worksheets( "Data" ),  // etc.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But where I had a question is how do I change the JMP script to ask it to Stack columns 2 through end?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following from doing a manual Stack in JMP and looking at the source script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Data Table( "Data" ) &amp;lt;&amp;lt; Stack(
	columns(
		:Name( "8/23/2021" ),
		:Name( "08/30/2021" ),
		:Name( "09/06/2021" ),
		:Name( "09/13/2021" ),
		:Name( "09/20/2021" )  // etc.
	),
	Source Label Column( "Failure Group Name" ),
	Stacked Data Column( "% Share, Week of" )
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and I have the framework of a For( function I can use:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For( c = 2, i &amp;lt;= N Col(), c++,
     //body//&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but I just don't quite know how to put them together. Is it putting the Stack( command inside the For( command somehow?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks to anyone who can help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 10 Jun 2023 23:42:16 GMT</pubDate>
    <dc:creator>jbolinger</dc:creator>
    <dc:date>2023-06-10T23:42:16Z</dc:date>
    <item>
      <title>JMP script to Stack from column 2-infinity from a weekly updating Excel table</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-script-to-Stack-from-column-2-infinity-from-a-weekly/m-p/449797#M69665</link>
      <description>&lt;P&gt;I have an Excel table that I am manually updating on a weekly basis. Next, I open this table in JMP and Stack every column from column 2 onward. With every weekly update, I add more columns to the initial table. I recently took an Intro to JMP Scripting class and I'm looking to automate this process a bit instead of re-Stacking it from scratch every time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what the table looks like in JMP before performing the Stack:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JMPexample.jpg" style="width: 523px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/38807i34C273087921D8DB/image-dimensions/523x238?v=v2" width="523" height="238" role="button" title="JMPexample.jpg" alt="JMPexample.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know how to import the Excel table into JMP via a script like so:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Open(
	"Drive:\Folder\File.xlsx",
	Worksheets( "Data" ),  // etc.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But where I had a question is how do I change the JMP script to ask it to Stack columns 2 through end?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following from doing a manual Stack in JMP and looking at the source script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Data Table( "Data" ) &amp;lt;&amp;lt; Stack(
	columns(
		:Name( "8/23/2021" ),
		:Name( "08/30/2021" ),
		:Name( "09/06/2021" ),
		:Name( "09/13/2021" ),
		:Name( "09/20/2021" )  // etc.
	),
	Source Label Column( "Failure Group Name" ),
	Stacked Data Column( "% Share, Week of" )
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and I have the framework of a For( function I can use:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For( c = 2, i &amp;lt;= N Col(), c++,
     //body//&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but I just don't quite know how to put them together. Is it putting the Stack( command inside the For( command somehow?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks to anyone who can help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:42:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-script-to-Stack-from-column-2-infinity-from-a-weekly/m-p/449797#M69665</guid>
      <dc:creator>jbolinger</dc:creator>
      <dc:date>2023-06-10T23:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: JMP script to Stack from column 2-infinity from a weekly updating Excel table</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-script-to-Stack-from-column-2-infinity-from-a-weekly/m-p/449817#M69666</link>
      <description>&lt;P&gt;I think that with Stack platform you can just use list of columns in the columns() argument&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");

cols_to_stack = {"NPN1", "PNP1", "PNP2"};

dt_stacked = dt &amp;lt;&amp;lt; Stack(
	columns(cols_to_stack),
	Source Label Column("Label"),
	Stacked Data Column("Data"),
	Drop All Other Columns(1)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So get a list of column names you have from the datatable you create from excel file by using &amp;lt;&amp;lt; Get Column Names(String), then drop first column with Remove From()&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Open(
	"$SAMPLE_IMPORT_DATA/Team Results.xlsx",
	Worksheets("Ungrouped Team Results"),
	Worksheet Settings(Headers Start on Row(3), Data Starts on Row(4))
);
//all columns
col_names = dt &amp;lt;&amp;lt; Get Column Names("String");

//drop first column
Remove From(col_names, 1);

//stack with remaining, won't work exactly like this with this example data, as data types aren't same
//dt_stacked = dt &amp;lt;&amp;lt; Stack(...)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;See Help / Scripting Index and search for different functions used here.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jan 2022 18:09:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-script-to-Stack-from-column-2-infinity-from-a-weekly/m-p/449817#M69666</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-01-07T18:09:53Z</dc:date>
    </item>
    <item>
      <title>Re: JMP script to Stack from column 2-infinity from a weekly updating Excel table</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-script-to-Stack-from-column-2-infinity-from-a-weekly/m-p/449818#M69667</link>
      <description>&lt;P&gt;Here is one way to handle this.&amp;nbsp; &amp;nbsp;BTW, your example data table could not be opened, so I have added one of my own.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);
dt=data table("Example");

colNames = dt &amp;lt;&amp;lt; get column names();

remove from(colNames, 1, 2 );

dt &amp;lt;&amp;lt; Stack(
	columns( colNames
	),
	Source Label Column( "Failure Group Name" ),
	Stacked Data Column( "% Share, Week of" )
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Jan 2022 18:20:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-script-to-Stack-from-column-2-infinity-from-a-weekly/m-p/449818#M69667</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-01-07T18:20:27Z</dc:date>
    </item>
    <item>
      <title>Re: JMP script to Stack from column 2-infinity from a weekly updating Excel table</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-script-to-Stack-from-column-2-infinity-from-a-weekly/m-p/449838#M69668</link>
      <description>&lt;P&gt;Thank you for the response, jthi! I'm gonna fiddle around with this and see if I can get it to work.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jan 2022 18:44:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-script-to-Stack-from-column-2-infinity-from-a-weekly/m-p/449838#M69668</guid>
      <dc:creator>jbolinger</dc:creator>
      <dc:date>2022-01-07T18:44:55Z</dc:date>
    </item>
    <item>
      <title>Re: JMP script to Stack from column 2-infinity from a weekly updating Excel table</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-script-to-Stack-from-column-2-infinity-from-a-weekly/m-p/449842#M69669</link>
      <description>&lt;P&gt;Thanks for the response, txnelson! This solution worked.&amp;nbsp;:D&lt;/img&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jan 2022 18:52:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-script-to-Stack-from-column-2-infinity-from-a-weekly/m-p/449842#M69669</guid>
      <dc:creator>jbolinger</dc:creator>
      <dc:date>2022-01-07T18:52:49Z</dc:date>
    </item>
  </channel>
</rss>

