<?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: Need to combine every n =6  number of columns using JMP script. in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Need-to-combine-every-n-6-number-of-columns-using-JMP-script/m-p/440153#M68849</link>
    <description>&lt;P&gt;Thanks Nelson, It worked.&lt;BR /&gt;&lt;BR /&gt;Thanks again.&lt;/P&gt;</description>
    <pubDate>Sat, 27 Nov 2021 09:22:40 GMT</pubDate>
    <dc:creator>HSS</dc:creator>
    <dc:date>2021-11-27T09:22:40Z</dc:date>
    <item>
      <title>Need to combine every n =6  number of columns using JMP script.</title>
      <link>https://community.jmp.com/t5/Discussions/Need-to-combine-every-n-6-number-of-columns-using-JMP-script/m-p/439235#M68774</link>
      <description>&lt;P&gt;Hi All, I need to combine every 6 columns of the data file and make it a new column. I am find if all the combine columns can be stored in new data file just to make code easy. Please see the attached sample data and output image I am looking for.&lt;BR /&gt;&lt;BR /&gt;Also how can I extract every 'n' element /and first 'n' element from a list ?&lt;BR /&gt;&lt;BR /&gt;Any help please.&lt;BR /&gt;Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sample Data.jpg" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/37910iC266E2F2DB4224FF/image-size/large?v=v2&amp;amp;px=999" role="button" title="Sample Data.jpg" alt="Sample Data.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 18:05:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Need-to-combine-every-n-6-number-of-columns-using-JMP-script/m-p/439235#M68774</guid>
      <dc:creator>HSS</dc:creator>
      <dc:date>2023-06-09T18:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: Need to combine every n =6  number of columns using JMP script.</title>
      <link>https://community.jmp.com/t5/Discussions/Need-to-combine-every-n-6-number-of-columns-using-JMP-script/m-p/439581#M68794</link>
      <description>&lt;P&gt;Hi Hari&lt;/P&gt;
&lt;P&gt;My solution as annex. (base on your sample data)&lt;/P&gt;
&lt;P&gt;Have a good day.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 06:00:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Need-to-combine-every-n-6-number-of-columns-using-JMP-script/m-p/439581#M68794</guid>
      <dc:creator>frank_wang</dc:creator>
      <dc:date>2021-11-24T06:00:48Z</dc:date>
    </item>
    <item>
      <title>Re: Need to combine every n =6  number of columns using JMP script.</title>
      <link>https://community.jmp.com/t5/Discussions/Need-to-combine-every-n-6-number-of-columns-using-JMP-script/m-p/439605#M68796</link>
      <description>&lt;P&gt;Given your input JMP table, the script below generates the new columns as your JPG file shows.&amp;nbsp; The JSL works if the input data are character columns or numeric columns.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1637747317452.png" style="width: 1115px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/37899i88A5A185D4FF1AD1/image-dimensions/1115x313?v=v2" width="1115" height="313" role="button" title="txnelson_0-1637747317452.png" alt="txnelson_0-1637747317452.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);
dt=current data table();

// Get all columns in data table
allCols = dt &amp;lt;&amp;lt; get column names(character,string);
// Setup the names of the new columns to be created
varNames = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

// Loop across the columns 6 at a time creating the new column
For(i=1,i&amp;lt;=nitems(allCols),i=i+6,
	dtName = substr(varNames,(i+5)/6,1);
	// Create the JSL command to generate the formula
	theExpr = "new column(dtName, character,
		formula(
			theList = {};
			insert into(theList,char(:\!"" || allCols[i] || "\!"n)); 
			insert into(theList,char(:\!"" || allCols[i+1] ||  "\!"n));
			insert into(theList,char(:\!"" || allCols[i+2] ||  "\!"n));
			insert into(theList,char(:\!"" || allCols[i+3] ||  "\!"n));
			insert into(theList,char(:\!"" || allCols[i+4] ||  "\!"n));
			insert into(theList,char(:\!"" || allCols[i+5] ||  "\!"n));
			Concat Items(theList,\!"-\!");
		)
	)";
	// Run the created JSL
	eval(parse(theExpr));
	// Turn column values into static values
	column(dt,dtName)&amp;lt;&amp;lt;delete formula;
	
	// Move the current 6 column after the created column
	dt &amp;lt;&amp;lt; Clear Column Selection();
	selList = allCols;
	remove from(selList, i+6, nitems(selList)-i+5);
	remove from(selList,1,i-1);
	dt &amp;lt;&amp;lt; select columns(selList);
	eval(parse("dt &amp;lt;&amp;lt; Move Selected Columns(After(:"||dtName||"));"));
);
dt &amp;lt;&amp;lt; Clear Column Selection();

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 10:02:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Need-to-combine-every-n-6-number-of-columns-using-JMP-script/m-p/439605#M68796</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-11-24T10:02:18Z</dc:date>
    </item>
    <item>
      <title>Re: Need to combine every n =6  number of columns using JMP script.</title>
      <link>https://community.jmp.com/t5/Discussions/Need-to-combine-every-n-6-number-of-columns-using-JMP-script/m-p/440153#M68849</link>
      <description>&lt;P&gt;Thanks Nelson, It worked.&lt;BR /&gt;&lt;BR /&gt;Thanks again.&lt;/P&gt;</description>
      <pubDate>Sat, 27 Nov 2021 09:22:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Need-to-combine-every-n-6-number-of-columns-using-JMP-script/m-p/440153#M68849</guid>
      <dc:creator>HSS</dc:creator>
      <dc:date>2021-11-27T09:22:40Z</dc:date>
    </item>
  </channel>
</rss>

