<?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 Summary with String_Aggregation in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Summary-with-String-Aggregation/m-p/367871#M61776</link>
    <description>&lt;P&gt;HI,&lt;/P&gt;&lt;P&gt;How can I code a table which:&lt;/P&gt;&lt;P&gt;- grouped based on characters and&lt;/P&gt;&lt;P&gt;- build the corresponding cells with conact_items (e.g. separated with ,).&lt;/P&gt;&lt;P&gt;- like the SQL code "SELECT sex, String_Agg(Name,', ') as ConcatName FROM 'Big Class'" GROUP BY sex&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know this would be possible with looping but I was wondering if there is another and more elegant way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Based on the "Big Class" table, the result should look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sex &amp;nbsp; &amp;nbsp; ConcatName&lt;/P&gt;&lt;P&gt;f&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; KATIE, LOUISE, ....&lt;BR /&gt;m &amp;nbsp; &amp;nbsp; &amp;nbsp; TIM, JAMES, ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2023 22:08:28 GMT</pubDate>
    <dc:creator>TWE</dc:creator>
    <dc:date>2023-06-09T22:08:28Z</dc:date>
    <item>
      <title>Summary with String_Aggregation</title>
      <link>https://community.jmp.com/t5/Discussions/Summary-with-String-Aggregation/m-p/367871#M61776</link>
      <description>&lt;P&gt;HI,&lt;/P&gt;&lt;P&gt;How can I code a table which:&lt;/P&gt;&lt;P&gt;- grouped based on characters and&lt;/P&gt;&lt;P&gt;- build the corresponding cells with conact_items (e.g. separated with ,).&lt;/P&gt;&lt;P&gt;- like the SQL code "SELECT sex, String_Agg(Name,', ') as ConcatName FROM 'Big Class'" GROUP BY sex&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know this would be possible with looping but I was wondering if there is another and more elegant way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Based on the "Big Class" table, the result should look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sex &amp;nbsp; &amp;nbsp; ConcatName&lt;/P&gt;&lt;P&gt;f&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; KATIE, LOUISE, ....&lt;BR /&gt;m &amp;nbsp; &amp;nbsp; &amp;nbsp; TIM, JAMES, ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 22:08:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Summary-with-String-Aggregation/m-p/367871#M61776</guid>
      <dc:creator>TWE</dc:creator>
      <dc:date>2023-06-09T22:08:28Z</dc:date>
    </item>
    <item>
      <title>Re: Summary with String_Aggregation</title>
      <link>https://community.jmp.com/t5/Discussions/Summary-with-String-Aggregation/m-p/367959#M61782</link>
      <description>&lt;P&gt;It seems like the tabulate platform needs a concatenate summary function.&amp;nbsp; Here is one way using a single loop on each row of a summary table:&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);

dt = Open("$Sample_data/big class.jmp");

//Table with each unique sex and count
dtSum = (dt &amp;lt;&amp;lt; Tabulate(
	Add Table( Row Table( Grouping Columns( :sex ) ) )
)) &amp;lt;&amp;lt; Make Into Data Table;

//blank column for concatenated names
dtSum &amp;lt;&amp;lt; New Column("Names", Character, "Nominal");

//loop for each row/sex
for each row(dtSum,

	// Use Eval and eval expression to insert the sex of the current 
	// row into the where expression of the other table
	Eval(Eval Expr(
	
		//fill in the names one row at a time, joining all values together
		:Names = char( Concat Items(
			
			//get names from main table matching the sex of the summary table
			dt:name[ dt &amp;lt;&amp;lt; Get Rows Where( dt:sex == Expr(:sex) ) ],
			","
		) )
	))
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2021 18:12:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Summary-with-String-Aggregation/m-p/367959#M61782</guid>
      <dc:creator>ih</dc:creator>
      <dc:date>2021-03-15T18:12:09Z</dc:date>
    </item>
    <item>
      <title>Re: Summary with String_Aggregation</title>
      <link>https://community.jmp.com/t5/Discussions/Summary-with-String-Aggregation/m-p/367994#M61783</link>
      <description>&lt;P&gt;Here's an attempt using JSL (JMP 15). It can be done interactively too, using transform and combine columns.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt1 = dt &amp;lt;&amp;lt; Transpose( columns( :name ), By( :sex ), Output Table( "Test" ) );
dt1 &amp;lt;&amp;lt; Combine Columns(
	delimiter( ", " ),
	Columns( 3 :: N Col( dt1 ) ),
	Selected Columns are Indicator Columns( 0 ),
	Column Name( "ConcatName" )
) &amp;lt;&amp;lt; deletecolumns( 2, 4 :: N Col( dt1 ) );
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Mar 2021 19:20:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Summary-with-String-Aggregation/m-p/367994#M61783</guid>
      <dc:creator>ms</dc:creator>
      <dc:date>2021-03-15T19:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: Summary with String_Aggregation</title>
      <link>https://community.jmp.com/t5/Discussions/Summary-with-String-Aggregation/m-p/368007#M61784</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/6657"&gt;@ih&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/182"&gt;@ms&lt;/a&gt;&amp;nbsp;have given you good answers but I was already working on this solution, so I thought I'd post it to show another way to do this, via JSL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Taking advantage of the &lt;A href="https://www.jmp.com/support/help/en/15.2/index.shtml#page/jmp/create-a-subset-data-table.shtml#ww337274" target="_self"&gt;Subset By&lt;/A&gt; option in &lt;A href="https://www.jmp.com/support/help/en/15.2/index.shtml%23page/jmp/create-a-subset-data-table.shtml" target="_self"&gt;Subset&lt;/A&gt; we can get a table for each subgroup, and then get the values from the Name column and use &lt;A href="https://www.jmp.com/support/help/en/15.2/index.shtml#page/jmp/character-functions-2.shtml#ww6146476" target="_self"&gt;Concat Items()&lt;/A&gt; to build the string of names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

dt_list = dt &amp;lt;&amp;lt; Subset(
	By( :sex ),
	All rows,
	Selected columns only( 0 ),
	columns( :name, :age, :height, :weight ),
	private
);

nt = New Table();
group_col_name = Word( 1, dt_list[1] &amp;lt;&amp;lt; get name, "=" );
nt &amp;lt;&amp;lt; New Column( group_col_name, character );
nt &amp;lt;&amp;lt; New Column( "concat name" );
nt &amp;lt;&amp;lt; add rows( N Items( dt_list ) );
For( i = 1, i &amp;lt;= N Items( dt_list ), i++,
	Column( nt, group_col_name )[i] = Word( 2, dt_list[i] &amp;lt;&amp;lt; get name, "= " );
	nt:concat name[i] = Concat Items( dt_list[i]:name &amp;lt;&amp;lt; get values, ", " );
);

For( i = 1, i &amp;lt;= N Items( dt_list ), i++,
	Close( dt_list[1], nosave )
);

dt_list = Empty();&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Mar 2021 19:49:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Summary-with-String-Aggregation/m-p/368007#M61784</guid>
      <dc:creator>Jeff_Perkinson</dc:creator>
      <dc:date>2021-03-15T19:49:22Z</dc:date>
    </item>
    <item>
      <title>Re: Summary with String_Aggregation</title>
      <link>https://community.jmp.com/t5/Discussions/Summary-with-String-Aggregation/m-p/368013#M61785</link>
      <description>&lt;P&gt;I wasn't aware of that Subset( By()...) returns a list. Can be very useful. Thanks Jeff!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/Marcus&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2021 20:07:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Summary-with-String-Aggregation/m-p/368013#M61785</guid>
      <dc:creator>ms</dc:creator>
      <dc:date>2021-03-15T20:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: Summary with String_Aggregation</title>
      <link>https://community.jmp.com/t5/Discussions/Summary-with-String-Aggregation/m-p/368184#M61804</link>
      <description>&lt;P&gt;Thanks to all approaches.&lt;/P&gt;&lt;P&gt;All of them are working well!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Mar 2021 10:50:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Summary-with-String-Aggregation/m-p/368184#M61804</guid>
      <dc:creator>TWE</dc:creator>
      <dc:date>2021-03-16T10:50:34Z</dc:date>
    </item>
    <item>
      <title>Re: Summary with String_Aggregation</title>
      <link>https://community.jmp.com/t5/Discussions/Summary-with-String-Aggregation/m-p/368185#M61805</link>
      <description>&lt;P&gt;Thanks ih,&lt;/P&gt;&lt;P&gt;I tried your approach with some tables and all are working. Sometimes it needed a bit time (depends on the table size).&lt;/P&gt;</description>
      <pubDate>Tue, 16 Mar 2021 10:54:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Summary-with-String-Aggregation/m-p/368185#M61805</guid>
      <dc:creator>TWE</dc:creator>
      <dc:date>2021-03-16T10:54:09Z</dc:date>
    </item>
    <item>
      <title>Re: Summary with String_Aggregation</title>
      <link>https://community.jmp.com/t5/Discussions/Summary-with-String-Aggregation/m-p/368187#M61807</link>
      <description>&lt;P&gt;Thanks ms,&lt;/P&gt;&lt;P&gt;this is a very fast way. I tried it based an huge LogFile and it works in seconds!&lt;/P&gt;</description>
      <pubDate>Tue, 16 Mar 2021 10:55:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Summary-with-String-Aggregation/m-p/368187#M61807</guid>
      <dc:creator>TWE</dc:creator>
      <dc:date>2021-03-16T10:55:15Z</dc:date>
    </item>
    <item>
      <title>Re: Summary with String_Aggregation</title>
      <link>https://community.jmp.com/t5/Discussions/Summary-with-String-Aggregation/m-p/368188#M61808</link>
      <description>&lt;P&gt;Thanks Jeff,&lt;/P&gt;&lt;P&gt;your solution is also working fast and I was also not aware of of the Subset(by()) command.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Mar 2021 10:56:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Summary-with-String-Aggregation/m-p/368188#M61808</guid>
      <dc:creator>TWE</dc:creator>
      <dc:date>2021-03-16T10:56:48Z</dc:date>
    </item>
  </channel>
</rss>

