<?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 Re: stack multiple series data with single label and keep original title in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/stack-multiple-series-data-with-single-label-and-keep-original/m-p/248814#M48842</link>
    <description>&lt;P&gt;If you Stack the data, then create a new column for the Fruit, and another one for the Color, you can then Split the data into the required data table.&lt;/P&gt;
&lt;P&gt;The script below illustrates how to accomplish this.&amp;nbsp; However, doing the steps interactively is how I build the script, so you can easily repeat the interactive steps.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

// Create the sample data table
dt = New Table( "Example",
	Add Rows( 3 ),
	New Script(
		"Source",
		Data Table( "Untitled 67" ) &amp;lt;&amp;lt; Split(
			Split By( :Column 2 ),
			Split( :Column 1 ),
			Sort by Column Property
		)
	),
	New Column( "List", Character, "Nominal", Set Values( {"a", "b", "c"} ) ),
	New Column( "Apple red", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 2, 3] ) ),
	New Column( "Apple yellow", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [11, 12, 13] ) ),
	New Column( "Banana red", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [21, 22, 23] ) ),
	New Column( "Banana yellow", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [31, 32, 33] ) )
);

// Stack the columns
dtStack = dt &amp;lt;&amp;lt; Stack(
	columns( :Apple red, :Apple yellow, :Banana yellow, :Banana red ),
	Source Label Column( "Label" ),
	Stacked Data Column( "Data" )
);

// Create 2 New Columns separating the fruit from the color
dtStack &amp;lt;&amp;lt; New Column("Fruit", character, formula(word(1,:Label," ")));
dtStack &amp;lt;&amp;lt; New Column("Color", character, formula(word(2,:Label," ")));

// Split the data back into the required new columns
dtFinal = dtStack &amp;lt;&amp;lt; Split(
	Split By( :Fruit ),
	Split( :Data ),
	Remaining Columns( Drop( :Label ) ),
	Sort by Column Property
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="banana.PNG" style="width: 436px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/21871i3B0F24512D30DF18/image-size/large?v=v2&amp;amp;px=999" role="button" title="banana.PNG" alt="banana.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 22 Feb 2020 14:17:37 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2020-02-22T14:17:37Z</dc:date>
    <item>
      <title>stack multiple series data with single label and keep original title</title>
      <link>https://community.jmp.com/t5/Discussions/stack-multiple-series-data-with-single-label-and-keep-original/m-p/248790#M48837</link>
      <description>&lt;P&gt;I have a table like this:&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;List&lt;/TD&gt;&lt;TD&gt;Apple red&lt;/TD&gt;&lt;TD&gt;Apple yellow&lt;/TD&gt;&lt;TD&gt;Banana red&lt;/TD&gt;&lt;TD&gt;Banana yellow&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;a&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;11&lt;/TD&gt;&lt;TD&gt;21&lt;/TD&gt;&lt;TD&gt;31&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;b&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;22&lt;/TD&gt;&lt;TD&gt;32&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;c&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;13&lt;/TD&gt;&lt;TD&gt;23&lt;/TD&gt;&lt;TD&gt;33&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;I would like to stack the data with multiple series (here is apple and banana), but only want 1 label for all series (here is red and yellow). I also want to keep the left of the title (here is apple and banana). The output is like:&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;List&lt;/TD&gt;&lt;TD&gt;Apple&lt;/TD&gt;&lt;TD&gt;Banana&lt;/TD&gt;&lt;TD&gt;group&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;a&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;21&lt;/TD&gt;&lt;TD&gt;red&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;a&lt;/TD&gt;&lt;TD&gt;11&lt;/TD&gt;&lt;TD&gt;31&lt;/TD&gt;&lt;TD&gt;yellow&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;b&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;22&lt;/TD&gt;&lt;TD&gt;red&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;b&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;32&lt;/TD&gt;&lt;TD&gt;yellow&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;c&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;23&lt;/TD&gt;&lt;TD&gt;red&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;c&lt;/TD&gt;&lt;TD&gt;13&lt;/TD&gt;&lt;TD&gt;33&lt;/TD&gt;&lt;TD&gt;yellow&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;I tried stack function but I think this needs some special script. Thank you so much!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Feb 2020 08:34:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/stack-multiple-series-data-with-single-label-and-keep-original/m-p/248790#M48837</guid>
      <dc:creator>jasongao</dc:creator>
      <dc:date>2020-02-22T08:34:53Z</dc:date>
    </item>
    <item>
      <title>Re: stack multiple series data with single label and keep original title</title>
      <link>https://community.jmp.com/t5/Discussions/stack-multiple-series-data-with-single-label-and-keep-original/m-p/248811#M48841</link>
      <description>&lt;P&gt;This can be done in three operations with no scripting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, use &lt;STRONG&gt;&lt;A href="https://www.jmp.com/support/help/en/15.1/#page/jmp/stack-columns.shtml#" target="_self"&gt;Tables-&amp;gt;Stack&lt;/A&gt;&lt;/STRONG&gt; to stack your four columns (&lt;FONT face="courier new,courier"&gt;Apple red, Apple yellow, Banana red, Banana yellow&lt;/FONT&gt;) into a single column.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2020-02-22_08-55-38.950.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/21863i85569B02E21952F3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="2020-02-22_08-55-38.950.png" alt="2020-02-22_08-55-38.950.png" /&gt;&lt;/span&gt; &lt;/P&gt;
&lt;P&gt;You'll end up with this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2020-02-22_08-58-15.533.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/21865i8469300E3DB83DA4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="2020-02-22_08-58-15.533.png" alt="2020-02-22_08-58-15.533.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Now, use &lt;A href="https://www.jmp.com/support/help/en/15.1/#page/jmp/make-a-column-into-multiple-columns.shtml" target="_blank"&gt;&lt;STRONG&gt;Cols-&amp;gt;Utlities-&amp;gt;Text to Columns&lt;/STRONG&gt;&lt;/A&gt; to separate the fruit from the color in your Label column. Put a space in the delimiter field.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2020-02-22_09-00-45.117.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/21866i443679BF32F1AD62/image-size/medium?v=v2&amp;amp;px=400" role="button" title="2020-02-22_09-00-45.117.png" alt="2020-02-22_09-00-45.117.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;You'll end up with two new columns. Rename them &lt;FONT face="courier new,courier"&gt;Fruit&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;Color&lt;/FONT&gt;. You can delete the &lt;FONT face="courier new,courier"&gt;Label&lt;/FONT&gt; column.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2020-02-22_09-02-54.120.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/21867iD0A86444CEAB24CF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="2020-02-22_09-02-54.120.png" alt="2020-02-22_09-02-54.120.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Now use &lt;A href="https://www.jmp.com/support/help/en/15.1/#page/jmp/split-columns.shtml#" target="_blank"&gt;Tables-&amp;gt;Split&lt;/A&gt; to split the &lt;FONT face="courier new,courier"&gt;Data&lt;/FONT&gt; column by &lt;FONT face="courier new,courier"&gt;Fruit.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2020-02-22_09-03-37.114.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/21868i185656C719210472/image-size/medium?v=v2&amp;amp;px=400" role="button" title="2020-02-22_09-03-37.114.png" alt="2020-02-22_09-03-37.114.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;Now you'll get the data table you want with, an &lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;Apple&lt;/FONT&gt;&lt;SPAN style="font-family: inherit;"&gt; column and &lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;Banana&lt;/FONT&gt;&lt;SPAN style="font-family: inherit;"&gt;&amp;nbsp;column.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2020-02-22_09-06-38.159.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/21870i6E23C336C91951D1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="2020-02-22_09-06-38.159.png" alt="2020-02-22_09-06-38.159.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Feb 2020 14:15:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/stack-multiple-series-data-with-single-label-and-keep-original/m-p/248811#M48841</guid>
      <dc:creator>Jeff_Perkinson</dc:creator>
      <dc:date>2020-02-22T14:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: stack multiple series data with single label and keep original title</title>
      <link>https://community.jmp.com/t5/Discussions/stack-multiple-series-data-with-single-label-and-keep-original/m-p/248814#M48842</link>
      <description>&lt;P&gt;If you Stack the data, then create a new column for the Fruit, and another one for the Color, you can then Split the data into the required data table.&lt;/P&gt;
&lt;P&gt;The script below illustrates how to accomplish this.&amp;nbsp; However, doing the steps interactively is how I build the script, so you can easily repeat the interactive steps.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

// Create the sample data table
dt = New Table( "Example",
	Add Rows( 3 ),
	New Script(
		"Source",
		Data Table( "Untitled 67" ) &amp;lt;&amp;lt; Split(
			Split By( :Column 2 ),
			Split( :Column 1 ),
			Sort by Column Property
		)
	),
	New Column( "List", Character, "Nominal", Set Values( {"a", "b", "c"} ) ),
	New Column( "Apple red", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 2, 3] ) ),
	New Column( "Apple yellow", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [11, 12, 13] ) ),
	New Column( "Banana red", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [21, 22, 23] ) ),
	New Column( "Banana yellow", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [31, 32, 33] ) )
);

// Stack the columns
dtStack = dt &amp;lt;&amp;lt; Stack(
	columns( :Apple red, :Apple yellow, :Banana yellow, :Banana red ),
	Source Label Column( "Label" ),
	Stacked Data Column( "Data" )
);

// Create 2 New Columns separating the fruit from the color
dtStack &amp;lt;&amp;lt; New Column("Fruit", character, formula(word(1,:Label," ")));
dtStack &amp;lt;&amp;lt; New Column("Color", character, formula(word(2,:Label," ")));

// Split the data back into the required new columns
dtFinal = dtStack &amp;lt;&amp;lt; Split(
	Split By( :Fruit ),
	Split( :Data ),
	Remaining Columns( Drop( :Label ) ),
	Sort by Column Property
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="banana.PNG" style="width: 436px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/21871i3B0F24512D30DF18/image-size/large?v=v2&amp;amp;px=999" role="button" title="banana.PNG" alt="banana.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Feb 2020 14:17:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/stack-multiple-series-data-with-single-label-and-keep-original/m-p/248814#M48842</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-02-22T14:17:37Z</dc:date>
    </item>
  </channel>
</rss>

