<?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: Script to loop thru and group columns by name, dynamically in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Script-to-loop-thru-and-group-columns-by-name-dynamically/m-p/470326#M71451</link>
    <description>&lt;P&gt;dtAggWide is there because it is the data table which has the columns you want to group. In the code above you are missing reference to it, easiest and best way to add it would be (this will avoid using Current Data Table() which might or might not work):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dtAggWide = dt &amp;lt;&amp;lt; Split(
       Split By( :RecipeStepId, :RecipeStepName, :ParameterName, :AggregateFunction ),
       Split( :Value ),
       Group( :Recipe, :ProcessTime, :Tool, :Chamber, :Lot, :WaferScribe ),
       Output Table( "AggWide" ),
       Remaining Columns( Drop All ),
       Sort by Column Property,
       dt &amp;lt;&amp;lt; sort( by( :Recipe, :Tool, :Chamber, :Lot, :WaferScribe ))
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And col_list is there to loop over the columns in dtAggWide and then add the columns to correct lists in the aa_groups associative array&lt;/P&gt;</description>
    <pubDate>Wed, 16 Mar 2022 15:51:56 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2022-03-16T15:51:56Z</dc:date>
    <item>
      <title>Script to loop thru and group columns by name, dynamically</title>
      <link>https://community.jmp.com/t5/Discussions/Script-to-loop-thru-and-group-columns-by-name-dynamically/m-p/470274#M71439</link>
      <description>&lt;P&gt;So I'm trying to figure this out and its just not quite working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've got a table with a key-value pair that I've SPLIT from Tall to Wide. I end up with about 10k columns that all have a regular naming structure, like&amp;nbsp;&lt;BR /&gt;"15.02.0 param1", "15.02 param2", "15.02 param3"...."15.03 param1", "15.03 param2", "15.03 param3",...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I look through all these columns and group them dynamically by the starting term? ie. all 15.02% columns in a group, all 15.03% cols, all 15.04%, ... all 17.06%....and name the group based on the groupby number?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My script just groups everything into a single group. ug.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//**split Aggregate Data from TALL to WIDE, grouping WIDE columns by StepID
dt = current data table();
Summarize( dt, RecipeStepIndex = by( :RecipeStepId) );//get list of unique RecipeStepID's

//split the table TALL to WIDE
dt &amp;lt;&amp;lt; Split(
       Split By( :RecipeStepId, :ParameterName, :AggregateFunction ),
       Split( :Value ),
       Group( :Recipe, :ProcessTime, :Tool, :Chamber, :Lot, :WaferScribe ),
       Output Table( "AggWide" ),
       Remaining Columns( Drop All ),
       Sort by Column Property,
       dt &amp;lt;&amp;lt; sort( by( :Recipe, :Tool, :Chamber, :Lot, :WaferScribe ))&lt;BR /&gt;
);

dtAggWide = current data table();
ColNamesList = dtAggWide &amp;lt;&amp;lt; get column names(string, continuous);  //get the column names of the WIDE table
//Create an empty list for the matching columns
RecipeStepList = {};
// Find matching column names
For( i = 1, i &amp;lt;= N items( RecipeStepIndex ), i++,
	For( j = 1, j &amp;lt;= N Items( ColNamesList ), j++,
		If( 
			Contains( ColNamesList[j], RecipeStepIndex[i] ),
				Insert Into( RecipeStepList, ColNamesList[j] ),						
		);
	);
);
// If groups of columns are found, create Col groupings
If( N Items( RecipeStepList ) &amp;gt; 0,
	dtAggWide &amp;lt;&amp;lt; select columns( RecipeStepList );
	dtAggWide &amp;lt;&amp;lt; group columns();
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Jun 2023 18:13:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-to-loop-thru-and-group-columns-by-name-dynamically/m-p/470274#M71439</guid>
      <dc:creator>aliegner1</dc:creator>
      <dc:date>2023-06-09T18:13:18Z</dc:date>
    </item>
    <item>
      <title>Re: Script to loop thru and group columns by name, dynamically</title>
      <link>https://community.jmp.com/t5/Discussions/Script-to-loop-thru-and-group-columns-by-name-dynamically/m-p/470309#M71441</link>
      <description>&lt;P&gt;There are many ways to do this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is one example which first builds the groups into associative array with the key as name of the group and value is list of columns in the group, then loops over that associative array to group columns in the data table. To get group names we use Word() function on the column names. &lt;STRONG&gt;This requires JMP16 due to using For Each&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
// this solution requires JMP16

dtAggWide = New Table("Untitled",
	Add Rows(0),
	New Column("15.02.0 param1", Numeric, "Continuous", Format("Best", 12), Set Values([])),
	New Column("15.02.0 param2", Numeric, "Continuous", Format("Best", 12), Set Values([])),
	New Column("15.02.0 param3", Numeric, "Continuous", Format("Best", 12), Set Values([])),
	New Column("15.03 param1", Numeric, "Continuous", Format("Best", 12), Set Values([])),
	New Column("15.03 param2", Numeric, "Continuous", Format("Best", 12), Set Values([]))
);

col_list = dtAggWide &amp;lt;&amp;lt; Get Column Names("String");

// first get the column group names and columns&lt;BR /&gt;// in this solution case we use associative array
aa_groups = Associative Array();
For Each({col_name}, col_list, 
	col_group = Word(1, col_name, " ");
	If(!Contains(aa_groups, col_group),
		aa_groups[col_group] = {};
	);
	Insert Into(aa_groups[col_group], col_name)
);
Show(aa_groups);

For Each({{key, value}}, aa_groups,
	dtAggWide &amp;lt;&amp;lt; Group Columns(key, value); 
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1647442521941.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/40861iA2B6E3F4B6F062C6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1647442521941.png" alt="jthi_0-1647442521941.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 14:57:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-to-loop-thru-and-group-columns-by-name-dynamically/m-p/470309#M71441</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-03-16T14:57:43Z</dc:date>
    </item>
    <item>
      <title>Re: Script to loop thru and group columns by name, dynamically</title>
      <link>https://community.jmp.com/t5/Discussions/Script-to-loop-thru-and-group-columns-by-name-dynamically/m-p/470317#M71445</link>
      <description>&lt;P&gt;thankyou, will try this shortly.&lt;/P&gt;&lt;P&gt;But what about building the grouping array list dynamically? Basically, each unique value of&amp;nbsp;:RecipeStepId should be a groupby name. I tried doing that at the beginning, before splitting the table, saving it to the "RecipeStepIndex"&lt;/P&gt;&lt;PRE class="language-jsl"&gt;&lt;CODE&gt;Summarize( dt, RecipeStepIndex = by( :RecipeStepId) );//get list of unique RecipeStepID's&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, 16 Mar 2022 15:20:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-to-loop-thru-and-group-columns-by-name-dynamically/m-p/470317#M71445</guid>
      <dc:creator>aliegner1</dc:creator>
      <dc:date>2022-03-16T15:20:28Z</dc:date>
    </item>
    <item>
      <title>Re: Script to loop thru and group columns by name, dynamically</title>
      <link>https://community.jmp.com/t5/Discussions/Script-to-loop-thru-and-group-columns-by-name-dynamically/m-p/470321#M71446</link>
      <description>&lt;P&gt;You could "pre-fill" the Associative array for example with the column names based on RecipeStepIndex. Most likely RecipeStepIndex will be found from the start of split column names so this should still work. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
// this solution requires JMP16

dtAggWide = New Table("Untitled",
	Add Rows(0),
	New Column("15.02.0 param1", Numeric, "Continuous", Format("Best", 12), Set Values([])),
	New Column("15.02.0 param2", Numeric, "Continuous", Format("Best", 12), Set Values([])),
	New Column("15.02.0 param3", Numeric, "Continuous", Format("Best", 12), Set Values([])),
	New Column("15.03 param1", Numeric, "Continuous", Format("Best", 12), Set Values([])),
	New Column("15.03 param2", Numeric, "Continuous", Format("Best", 12), Set Values([]))
);

col_list = dtAggWide &amp;lt;&amp;lt; Get Column Names("String");

// first get the column group names and columns// in this solution case we use associative array
aa_groups = Associative Array();

//Summarize(dt, RecipeStepIndex = by(:RecipeStepId));//get list of unique RecipeStepID's
RecipeStepIndex = {"15.02.0", "15.03"};
aa_groups = Associative Array(RecipeStepIndex, Repeat({{}}, N Items(RecipeStepIndex)));

For Each({col_name}, col_list, 
	col_group = Word(1, col_name, " ");
	Insert Into(aa_groups[col_group], col_name)
);

For Each({{key, value}}, aa_groups,
	dtAggWide &amp;lt;&amp;lt; Group Columns(key, value); 
);&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, 16 Mar 2022 15:27:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-to-loop-thru-and-group-columns-by-name-dynamically/m-p/470321#M71446</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-03-16T15:27:58Z</dc:date>
    </item>
    <item>
      <title>Re: Script to loop thru and group columns by name, dynamically</title>
      <link>https://community.jmp.com/t5/Discussions/Script-to-loop-thru-and-group-columns-by-name-dynamically/m-p/470325#M71450</link>
      <description>&lt;P&gt;Hmm. I'm a bit stuck and not sure what you're doing here.&lt;BR /&gt;&lt;BR /&gt;Why still have dtAggWide and col_list?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//*****************************************************************
//**split Aggregate Data from TALL to WIDE, grouping WIDE columns by StepID
dt = current data table();

//Build and prefill an Array of names of the RecipeStepId
aa_groups = Associative Array();
Summarize( dt, RecipeStepIndex = by( :RecipeStepId) );//get list of unique RecipeStepID's
aa_groups = Associative Array(RecipeStepIndex, Repeat({{}}, N Items(RecipeStepIndex)));

//split the table TALL to WIDE
dt &amp;lt;&amp;lt; Split(
       Split By( :RecipeStepId, :RecipeStepName, :ParameterName, :AggregateFunction ),
       Split( :Value ),
       Group( :Recipe, :ProcessTime, :Tool, :Chamber, :Lot, :WaferScribe ),
       Output Table( "AggWide" ),
       Remaining Columns( Drop All ),
       Sort by Column Property,
       dt &amp;lt;&amp;lt; sort( by( :Recipe, :Tool, :Chamber, :Lot, :WaferScribe ))
);

//Group the Cols by name of RecipeStepId
For Each({col_name}, col_list, 
	col_group = Word(1, col_name, " ");
	Insert Into(aa_groups[col_group], col_name)
);
For Each({{key, value}}, aa_groups,
	dtAggWide &amp;lt;&amp;lt; Group Columns(key, value); 
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Mar 2022 15:43:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-to-loop-thru-and-group-columns-by-name-dynamically/m-p/470325#M71450</guid>
      <dc:creator>aliegner1</dc:creator>
      <dc:date>2022-03-16T15:43:04Z</dc:date>
    </item>
    <item>
      <title>Re: Script to loop thru and group columns by name, dynamically</title>
      <link>https://community.jmp.com/t5/Discussions/Script-to-loop-thru-and-group-columns-by-name-dynamically/m-p/470326#M71451</link>
      <description>&lt;P&gt;dtAggWide is there because it is the data table which has the columns you want to group. In the code above you are missing reference to it, easiest and best way to add it would be (this will avoid using Current Data Table() which might or might not work):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dtAggWide = dt &amp;lt;&amp;lt; Split(
       Split By( :RecipeStepId, :RecipeStepName, :ParameterName, :AggregateFunction ),
       Split( :Value ),
       Group( :Recipe, :ProcessTime, :Tool, :Chamber, :Lot, :WaferScribe ),
       Output Table( "AggWide" ),
       Remaining Columns( Drop All ),
       Sort by Column Property,
       dt &amp;lt;&amp;lt; sort( by( :Recipe, :Tool, :Chamber, :Lot, :WaferScribe ))
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And col_list is there to loop over the columns in dtAggWide and then add the columns to correct lists in the aa_groups associative array&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 15:51:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-to-loop-thru-and-group-columns-by-name-dynamically/m-p/470326#M71451</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-03-16T15:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: Script to loop thru and group columns by name, dynamically</title>
      <link>https://community.jmp.com/t5/Discussions/Script-to-loop-thru-and-group-columns-by-name-dynamically/m-p/470432#M71456</link>
      <description>&lt;P&gt;OK, I think I see what you mean, I was confused why you were creating a new dt, but looks like just for the example.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;your second set of code doesn't seem to work for me, but the first set did. Any idea what this error means?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="aliegner1_0-1647450644509.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/40869iE8BAD25C004E6161/image-size/medium?v=v2&amp;amp;px=400" role="button" title="aliegner1_0-1647450644509.png" alt="aliegner1_0-1647450644509.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//Group the Cols by name of RecipeStepId
col_list = dtAggWIDE &amp;lt;&amp;lt; Get Column Names("String");

For Each({col_name}, col_list, 
	col_group = Word(1, col_name, " ");
	If(!Contains(aa_groups, col_group),
		aa_groups[col_group] = {};
	);
	Insert Into(aa_groups[col_group], col_name)
);

Show(aa_groups);

For Each({{key, value}}, aa_groups,
	dtAggWide &amp;lt;&amp;lt; Group Columns(key, value); 
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="aliegner1_1-1647450778727.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/40871iB32A3F27FC4A96C0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="aliegner1_1-1647450778727.png" alt="aliegner1_1-1647450778727.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 17:13:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-to-loop-thru-and-group-columns-by-name-dynamically/m-p/470432#M71456</guid>
      <dc:creator>aliegner1</dc:creator>
      <dc:date>2022-03-16T17:13:15Z</dc:date>
    </item>
    <item>
      <title>Re: Script to loop thru and group columns by name, dynamically</title>
      <link>https://community.jmp.com/t5/Discussions/Script-to-loop-thru-and-group-columns-by-name-dynamically/m-p/470435#M71458</link>
      <description>&lt;P&gt;I think that error means that you don't have a key in associative array. If you tried the second code, does your code have this line:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;aa_groups = Associative Array(RecipeStepIndex, Repeat({{}}, N Items(RecipeStepIndex)));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;it is used to initialize aa_groups. Also if the &lt;CODE class=" language-jsl"&gt;RecipeStepIndex&lt;/CODE&gt; do not match with &lt;CODE class=" language-jsl"&gt;col_group = Word(1, col_name, " ");&lt;/CODE&gt; you will get that error. You might have to add some extra handling for cases like that (add group which will collect all the missing columns or only add columns which are found).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This should skip columns which do not have matching group.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For Each({col_name}, col_list, 
	col_group = Word(1, col_name, " ");
	If(!Contains(aa_groups, col_group),
		aa_groups[col_group] = Eval List({col_name});
	,
		Insert Into(aa_groups[col_group], col_name);
	);
);&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, 16 Mar 2022 17:32:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-to-loop-thru-and-group-columns-by-name-dynamically/m-p/470435#M71458</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-03-16T17:32:47Z</dc:date>
    </item>
    <item>
      <title>Re: Script to loop thru and group columns by name, dynamically</title>
      <link>https://community.jmp.com/t5/Discussions/Script-to-loop-thru-and-group-columns-by-name-dynamically/m-p/470441#M71464</link>
      <description>&lt;P&gt;gotchya. I figured out how to get both versions to work! Big thanks and kudos.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For anyone in the future, here's my finished versions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;V1=&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//**split Aggregate Data from TALL to WIDE, grouping WIDE columns by StepID
dt = current data table();

//Build and prefill an Array of names of the RecipeStepId
Summarize( dt, RecipeStepIndex = by( :RecipeStepId) );//get list of unique RecipeStepID's
aa_groups = Associative Array(RecipeStepIndex, Repeat({{}}, N Items(RecipeStepIndex)));

//split the table TALL to WIDE
dt &amp;lt;&amp;lt; Split(
       Split By( :RecipeStepId, :ParameterName, :AggregateFunction ),
       Split( :Value ),
       Group( :Recipe, :ProcessTime, :Tool, :Chamber, :Lot, :WaferScribe ),
       Output Table( "AggWide" ),
       Remaining Columns( Drop All ),
       Sort by Column Property,
       dt &amp;lt;&amp;lt; sort( by( :Recipe, :Tool, :Chamber, :Lot, :WaferScribe ))
);

//Group the Cols by name of RecipeStepId
col_list = dtAggWIDE &amp;lt;&amp;lt; Get Column Names("String"); //get the col list
For Each({col_name}, col_list, 
	col_group = Word(1, col_name, " ");
	If(!Contains(aa_groups, col_group),
		aa_groups[col_group] = Eval List({col_name});
	,
		Insert Into(aa_groups[col_group], col_name);
	);
);

For Each({{key, value}}, aa_groups,					//perform the grouping
	dtAggWide &amp;lt;&amp;lt; Group Columns(key, value); 
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;V2=&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//**split Aggregate Data from TALL to WIDE, grouping WIDE columns by StepID
dt = current data table();

//Build and prefill an Array of names of the RecipeStepId
Summarize( dt, RecipeStepIndex = by( :RecipeStepId) );//get list of unique RecipeStepID's
aa_groups = Associative Array();

//split the table TALL to WIDE
dt &amp;lt;&amp;lt; Split(
       Split By( :RecipeStepId, :ParameterName, :AggregateFunction ),
       Split( :Value ),
       Group( :Recipe, :ProcessTime, :Tool, :Chamber, :Lot, :WaferScribe ),
       Output Table( "AggWide" ),
       Remaining Columns( Drop All ),
       Sort by Column Property,
       dt &amp;lt;&amp;lt; sort( by( :Recipe, :Tool, :Chamber, :Lot, :WaferScribe ))
);

//Group the Cols by name of RecipeStepId
col_list = dtAggWide &amp;lt;&amp;lt; Get Column Names("String");
For Each({col_name}, col_list, 
	col_group = Word(1, col_name, " ");
	If(!Contains(aa_groups, col_group),
		aa_groups[col_group] = {};
	);
	Insert Into(aa_groups[col_group], col_name)
);

For Each({{key, value}}, aa_groups,					//perform the grouping
	dtAggWide &amp;lt;&amp;lt; Group Columns(key, value); 
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Mar 2022 18:36:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-to-loop-thru-and-group-columns-by-name-dynamically/m-p/470441#M71464</guid>
      <dc:creator>aliegner1</dc:creator>
      <dc:date>2022-03-16T18:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: Script to loop thru and group columns by name, dynamically</title>
      <link>https://community.jmp.com/t5/Discussions/Script-to-loop-thru-and-group-columns-by-name-dynamically/m-p/725670#M91039</link>
      <description>&lt;P&gt;Nice script!&amp;nbsp; I tweaked it a bit to group all data columns with the matching first 4 characters in the column title.&amp;nbsp; The data I get is named in that way and this makes it much easier to look at like data kinds.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();

col_list = dt &amp;lt;&amp;lt; Get Column Names("String");

// first get the column group names and columns// in this solution case we use associative array
aa_groups = Associative Array();
For Each({col_name}, col_list, 
	col_group = Substr( col_name, 1, 4 );
	If(!Contains(aa_groups, col_group),
		aa_groups[col_group] = {};
	);
	Insert Into(aa_groups[col_group], col_name)
);
Show(aa_groups);

For Each({{key, value}}, aa_groups,
	dt &amp;lt;&amp;lt; Group Columns(key, value); 
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 14:22:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-to-loop-thru-and-group-columns-by-name-dynamically/m-p/725670#M91039</guid>
      <dc:creator>SpannerHead</dc:creator>
      <dc:date>2024-02-28T14:22:57Z</dc:date>
    </item>
    <item>
      <title>Re: Script to loop thru and group columns by name, dynamically</title>
      <link>https://community.jmp.com/t5/Discussions/Script-to-loop-thru-and-group-columns-by-name-dynamically/m-p/738094#M91936</link>
      <description>&lt;P&gt;Any way to make this search for a specific character, then use that as the group name? That way its a dynamic length for the first section?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2024 20:58:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-to-loop-thru-and-group-columns-by-name-dynamically/m-p/738094#M91936</guid>
      <dc:creator>TriangularLlama</dc:creator>
      <dc:date>2024-03-22T20:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: Script to loop thru and group columns by name, dynamically</title>
      <link>https://community.jmp.com/t5/Discussions/Script-to-loop-thru-and-group-columns-by-name-dynamically/m-p/738214#M91948</link>
      <description>&lt;P&gt;You would modify the part where col_group is determined and then continue accordingly.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Mar 2024 13:33:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-to-loop-thru-and-group-columns-by-name-dynamically/m-p/738214#M91948</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-03-23T13:33:06Z</dc:date>
    </item>
  </channel>
</rss>

