<?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: Creating Groups after Database Query in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Creating-Groups-after-Database-Query/m-p/806916#M98552</link>
    <description>&lt;P&gt;This partially depends on your data but the general idea usually is&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Get list of your columns&lt;/LI&gt;
&lt;LI&gt;loop over the list while collecting the columns into appropriate groups&lt;/LI&gt;
&lt;LI&gt;loop over the appropriate groups and create the column groups&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;For Each() for looping, Associative Array() for data structure and possibly Starts With() for checking for groups (or Word(1,...))&lt;/P&gt;</description>
    <pubDate>Fri, 18 Oct 2024 16:36:20 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2024-10-18T16:36:20Z</dc:date>
    <item>
      <title>Creating Groups after Database Query</title>
      <link>https://community.jmp.com/t5/Discussions/Creating-Groups-after-Database-Query/m-p/806898#M98550</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a database query that returns a large table, 200+ columns, &amp;nbsp;and would like to clean it up before working with.&lt;/P&gt;&lt;P&gt;The columns have initial terms that signify the metrology tool source such as Raman, XRD, XRF, BET, PSA,...&lt;/P&gt;&lt;P&gt;For each of these terms I would like to create a group and use the name from the above list to act as the name of the group.&lt;/P&gt;&lt;P&gt;for example there are 20 columns that start with the term Raman and I would like them all grouped together.&lt;/P&gt;&lt;P&gt;How should I script it? &amp;nbsp;I tried to create a list using Name starts with("Raman") but that seems to return an empty list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Side note: I asked ChatGPT but that was useless.&lt;/P&gt;&lt;P&gt;Andy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Oct 2024 16:12:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Creating-Groups-after-Database-Query/m-p/806898#M98550</guid>
      <dc:creator>Hegedus1</dc:creator>
      <dc:date>2024-10-18T16:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Groups after Database Query</title>
      <link>https://community.jmp.com/t5/Discussions/Creating-Groups-after-Database-Query/m-p/806916#M98552</link>
      <description>&lt;P&gt;This partially depends on your data but the general idea usually is&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Get list of your columns&lt;/LI&gt;
&lt;LI&gt;loop over the list while collecting the columns into appropriate groups&lt;/LI&gt;
&lt;LI&gt;loop over the appropriate groups and create the column groups&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;For Each() for looping, Associative Array() for data structure and possibly Starts With() for checking for groups (or Word(1,...))&lt;/P&gt;</description>
      <pubDate>Fri, 18 Oct 2024 16:36:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Creating-Groups-after-Database-Query/m-p/806916#M98552</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-10-18T16:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Groups after Database Query</title>
      <link>https://community.jmp.com/t5/Discussions/Creating-Groups-after-Database-Query/m-p/806926#M98555</link>
      <description>&lt;P&gt;This is where I am starting and no this does not work.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here(1);
dt = Current Data Table();
 
CL = dt &amp;lt;&amp;lt; Get Column Names();
Raman={};
For Each ( {value,index},CL,if(starts with(value,"Raman"),Raman&amp;lt;&amp;lt;insert item(value),));
print(raman);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Next steps&lt;/P&gt;&lt;P&gt;Andy&lt;/P&gt;</description>
      <pubDate>Fri, 18 Oct 2024 17:51:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Creating-Groups-after-Database-Query/m-p/806926#M98555</guid>
      <dc:creator>Hegedus1</dc:creator>
      <dc:date>2024-10-18T17:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Groups after Database Query</title>
      <link>https://community.jmp.com/t5/Discussions/Creating-Groups-after-Database-Query/m-p/806933#M98559</link>
      <description>&lt;P&gt;Few questions:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Do you wish to group all columns?&lt;/LI&gt;
&lt;LI&gt;Do your columns have clear separator for the group such as underscore (Raman_)&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Current Data Table();
 
CL = dt &amp;lt;&amp;lt; Get Column Names();
Raman = {};
For Each({value}, CL,
	If(Starts With(value, "Raman"), 
		Insert Into(Raman, value);
	);
);

dt &amp;lt;&amp;lt; Group Columns("Raman", Raman);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And full example based on the examples I have&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = New Table("Untitled 2",
	Add Rows(1),
	Compress File When Saved(1),
	New Column("Raman1", Numeric, "Continuous", Format("Best", 12), Set Values([.])),
	New Column("Raman2", Numeric, "Continuous", Format("Best", 12), Set Values([.])),
	New Column("XRD1", Numeric, "Continuous", Format("Best", 12), Set Values([.])),
	New Column("Raman3", Numeric, "Continuous", Format("Best", 12), Set Values([.])),
	New Column("XRD2", Numeric, "Continuous", Format("Best", 12), Set Values([.]))
);

collist = dt &amp;lt;&amp;lt; Get Column Names("String");
aa_groups = Associative Array();
aa_groups["Raman"] = {};
aa_groups["XRD"] = {};

For Each({groupname}, aa_groups &amp;lt;&amp;lt; get keys,
	For Each({value}, collist,
		If(Starts With(value, groupname), 
			Insert Into(aa_groups[groupname], value);
		);
	);	
);

For Each({{groupname, cols}}, aa_groups,
	dt &amp;lt;&amp;lt; Group Columns(groupname, cols);
);&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-1729275364810.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/69313i2E07570AEF654030/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1729275364810.png" alt="jthi_0-1729275364810.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Oct 2024 18:16:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Creating-Groups-after-Database-Query/m-p/806933#M98559</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-10-18T18:16:12Z</dc:date>
    </item>
  </channel>
</rss>

