<?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: Stacking columns by group in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Stacking-columns-by-group/m-p/47134#M26862</link>
    <description>&lt;P&gt;Thanks you very much.&lt;/P&gt;</description>
    <pubDate>Sun, 12 Nov 2017 15:39:51 GMT</pubDate>
    <dc:creator>masum111bd</dc:creator>
    <dc:date>2017-11-12T15:39:51Z</dc:date>
    <item>
      <title>Stacking columns by group</title>
      <link>https://community.jmp.com/t5/Discussions/Stacking-columns-by-group/m-p/47115#M26854</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to JSL scripting. I want to stack columns coming from same common name (upto certain length). Such as I have column name "66_CORR_B1_W00",&amp;nbsp;&lt;SPAN&gt;"66_CORR_B1_W01" and so on upto&amp;nbsp;"66_CORR_B1_W12". They should be in single column named&lt;/SPAN&gt;&lt;SPAN&gt;""66_CORR_B1". And this will repeat for another column group name starring with "66_CORR_B2". There could be 20 groups of these columns. Finally I want 20 columns that comes from 20 groups of columns.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Here I attach a sample data table.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks in advance.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Muhammad Rahman&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 23:24:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Stacking-columns-by-group/m-p/47115#M26854</guid>
      <dc:creator>masum111bd</dc:creator>
      <dc:date>2023-06-09T23:24:31Z</dc:date>
    </item>
    <item>
      <title>Re: Stacking columns by group</title>
      <link>https://community.jmp.com/t5/Discussions/Stacking-columns-by-group/m-p/47133#M26861</link>
      <description>&lt;P&gt;Below is a script that works for the sample data you encluded in your initial Discussion Entry.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Data Table( "Sample_data" );

ColList = dt &amp;lt;&amp;lt; get column names( string, numeric );
// Loop across the column names and find only the 
// columns desired
For( i = N Items( ColList ), i &amp;gt;= 1, i--,
	If( Contains( ColList[i], "66_CORR_B" ) == 0,
		ColList = Remove( ColList, i, 1 )
	)
);
// Sort the columns to ensure they are in the correct order
// for the contiguous stacking
ColList = Sort List( ColList );
// Stack the data
Data Table( "Sample_data" ) &amp;lt;&amp;lt; Stack(
	columns( ColList ),
	Source Label Column( "Label" ),
	Stacked Data Column( "Data" ),
	Number of Series( 2 ),
	Contiguous
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The script is very basic, in that it does not check for situations where there are not equal number of columns for each grouping, the columns to be selected do not follow a very good set of names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But it should give you an idea of how to procede&lt;/P&gt;</description>
      <pubDate>Sun, 12 Nov 2017 13:08:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Stacking-columns-by-group/m-p/47133#M26861</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-11-12T13:08:01Z</dc:date>
    </item>
    <item>
      <title>Re: Stacking columns by group</title>
      <link>https://community.jmp.com/t5/Discussions/Stacking-columns-by-group/m-p/47134#M26862</link>
      <description>&lt;P&gt;Thanks you very much.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Nov 2017 15:39:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Stacking-columns-by-group/m-p/47134#M26862</guid>
      <dc:creator>masum111bd</dc:creator>
      <dc:date>2017-11-12T15:39:51Z</dc:date>
    </item>
  </channel>
</rss>

