<?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 Concatenating/Merging/Updating  Multiple Data Tables from a loop  into one in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Concatenating-Merging-Updating-Multiple-Data-Tables-from-a-loop/m-p/300287#M55933</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have the following problem:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;a) I am generating a table (call it table dt) with mutiple columns. However I am interested to only look at&amp;nbsp; specific pattern (say - "ABC@XYZ") in the col names along with two other columns (say - "LCOL", "WCOL"). I am generating that table. ( Calling that table dtB)&lt;/P&gt;&lt;P&gt;Next&lt;/P&gt;&lt;P&gt;b) I use the table dtB, pulls its column and use a for loop to generate a summary table for each such column which matches the pattern in Col Name.&lt;/P&gt;&lt;P&gt;c) I have created an empty table list, dt_sum_all&amp;nbsp;&lt;/P&gt;&lt;P&gt;d) Now my goal is to obtain all the summary values of the columns which match the pattern into one table along with LCOL &amp;amp; WCOL column. ( I am getting N tables for N such columns, if I do not use the new table, but that is not what I want - &lt;STRONG&gt;I want 1 table&lt;/STRONG&gt;)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;e&lt;EM&gt;) Also at the end once I have a single table, I want to rename the Cols ( usually it appends SUM at the beginning of each column), like SUM (&lt;A href="mailto:ABC@XYZ_1AS" target="_blank" rel="noopener"&gt;ABC@XYZ_1AS&lt;/A&gt;)&amp;nbsp; to&amp;nbsp;&lt;A href="mailto:ABC@XYZ_1AS" target="_blank" rel="noopener"&gt;ABC@XYZ_1AS&lt;/A&gt;&amp;nbsp;. Since I have many columns, I want to do it in a loop or similar.&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I have till now is the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = currentdatatable();

Wait(1); 

colsd = dt &amp;lt;&amp;lt; get column names( string );
pattern = "ABC@XYZ";
nd = N Items( colsd );
selCols = {"LCOL", "WCOL"};


For( i = 1, i &amp;lt;= nd, i++,
If( Contains( colsd[i], pattern ),
Insert Into( selCols, colsd[i] )
)
);


dtB = dt &amp;lt;&amp;lt; Subset(
	  All rows,
	  Columns(selCols)
);

colNameList= dtB &amp;lt;&amp;lt; get column names( string );

Wait(1);

dt_sum_all = {}; 

For( i = 1, i &amp;lt;= N Items( colNameList ), i++,
	If( Contains( colNameList[i], pattern),
		dt_sum =  dtB &amp;lt;&amp;lt; Summary(
	    Group( :LCOL, :WCOL ),
		Sum(colNameList[i]),
        Freq( "None" ),
	    Weight( "None" ),
		) &amp;lt;&amp;lt; show window(0);	
		);
		Insert Into(dt_sum_all, dt_sum);
		//Data Table (dt_sum_all) &amp;lt;&amp;lt; Update (
			///With(Data Table(dt_sum)),
			//Match Columns(:LCOL = :LCOL, :WCOL=:WCOL)
		);
		
	////column(dt_sum, "SUM("||colNameList[i] || ")"  ) &amp;lt;&amp;lt; set name(colNameList[i]);	
	///);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The above code is not working and I am getting multiple tables for each column, instead of one merged/updated one. So not getting one table. Can anyone please help. Thanks.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 10 Jun 2023 23:18:39 GMT</pubDate>
    <dc:creator>tnodd</dc:creator>
    <dc:date>2023-06-10T23:18:39Z</dc:date>
    <item>
      <title>Concatenating/Merging/Updating  Multiple Data Tables from a loop  into one</title>
      <link>https://community.jmp.com/t5/Discussions/Concatenating-Merging-Updating-Multiple-Data-Tables-from-a-loop/m-p/300287#M55933</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have the following problem:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;a) I am generating a table (call it table dt) with mutiple columns. However I am interested to only look at&amp;nbsp; specific pattern (say - "ABC@XYZ") in the col names along with two other columns (say - "LCOL", "WCOL"). I am generating that table. ( Calling that table dtB)&lt;/P&gt;&lt;P&gt;Next&lt;/P&gt;&lt;P&gt;b) I use the table dtB, pulls its column and use a for loop to generate a summary table for each such column which matches the pattern in Col Name.&lt;/P&gt;&lt;P&gt;c) I have created an empty table list, dt_sum_all&amp;nbsp;&lt;/P&gt;&lt;P&gt;d) Now my goal is to obtain all the summary values of the columns which match the pattern into one table along with LCOL &amp;amp; WCOL column. ( I am getting N tables for N such columns, if I do not use the new table, but that is not what I want - &lt;STRONG&gt;I want 1 table&lt;/STRONG&gt;)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;e&lt;EM&gt;) Also at the end once I have a single table, I want to rename the Cols ( usually it appends SUM at the beginning of each column), like SUM (&lt;A href="mailto:ABC@XYZ_1AS" target="_blank" rel="noopener"&gt;ABC@XYZ_1AS&lt;/A&gt;)&amp;nbsp; to&amp;nbsp;&lt;A href="mailto:ABC@XYZ_1AS" target="_blank" rel="noopener"&gt;ABC@XYZ_1AS&lt;/A&gt;&amp;nbsp;. Since I have many columns, I want to do it in a loop or similar.&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I have till now is the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = currentdatatable();

Wait(1); 

colsd = dt &amp;lt;&amp;lt; get column names( string );
pattern = "ABC@XYZ";
nd = N Items( colsd );
selCols = {"LCOL", "WCOL"};


For( i = 1, i &amp;lt;= nd, i++,
If( Contains( colsd[i], pattern ),
Insert Into( selCols, colsd[i] )
)
);


dtB = dt &amp;lt;&amp;lt; Subset(
	  All rows,
	  Columns(selCols)
);

colNameList= dtB &amp;lt;&amp;lt; get column names( string );

Wait(1);

dt_sum_all = {}; 

For( i = 1, i &amp;lt;= N Items( colNameList ), i++,
	If( Contains( colNameList[i], pattern),
		dt_sum =  dtB &amp;lt;&amp;lt; Summary(
	    Group( :LCOL, :WCOL ),
		Sum(colNameList[i]),
        Freq( "None" ),
	    Weight( "None" ),
		) &amp;lt;&amp;lt; show window(0);	
		);
		Insert Into(dt_sum_all, dt_sum);
		//Data Table (dt_sum_all) &amp;lt;&amp;lt; Update (
			///With(Data Table(dt_sum)),
			//Match Columns(:LCOL = :LCOL, :WCOL=:WCOL)
		);
		
	////column(dt_sum, "SUM("||colNameList[i] || ")"  ) &amp;lt;&amp;lt; set name(colNameList[i]);	
	///);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The above code is not working and I am getting multiple tables for each column, instead of one merged/updated one. So not getting one table. Can anyone please help. Thanks.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:18:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Concatenating-Merging-Updating-Multiple-Data-Tables-from-a-loop/m-p/300287#M55933</guid>
      <dc:creator>tnodd</dc:creator>
      <dc:date>2023-06-10T23:18:39Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating/Merging/Updating  Multiple Data Tables from a loop  into one</title>
      <link>https://community.jmp.com/t5/Discussions/Concatenating-Merging-Updating-Multiple-Data-Tables-from-a-loop/m-p/301231#M55936</link>
      <description>&lt;P&gt;If I am reading your code correctly, what you want to end up with is a data table of summary data for a set of columns that match a pattern in the original data table.&lt;/P&gt;
&lt;P&gt;I believe you were working a lot harder than you had to.&amp;nbsp; Below is an example script, using most of your code, but working on the Semiconductor Capability sample data table, where the names of the lot and wafer columns are lot_id and wafer, rather than your Lcol and Wcol.&amp;nbsp; I have eliminated the dtB data table, because unless you need it for something later in the script, it certainly does not need to be created just to then go and create summary data for it.&amp;nbsp; The summary data can come directly from the original data table.&amp;nbsp; Also, there is no need to summarize each column one at a time.&amp;nbsp; All columns can easily be summarized at once.&amp;nbsp; Thus, no Updatie need to be run.&amp;nbsp; Finally, there is an option in the Summary Platform, that will allow for the column names to be given the same name as the input column name, so there is no need to go through the renaming of the columns in the summary table.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );

Wait( 0 ); 

colsd = dt &amp;lt;&amp;lt; get column names( string );
pattern = "PNP";
nd = N Items( colsd );
selCols = {"lot_id", "wafer"};


For( i = 1, i &amp;lt;= nd, i++,
	If( Contains( colsd[i], pattern ),
		Insert Into( selCols, colsd[i] )
	)
);

dt_sum = dt &amp;lt;&amp;lt; Summary(
	Group( :lot_id, :wafer ),
	Sum( colNameList[Index( 3, N Items( colNameList ) )] ),
	Freq( "None" ),
	Weight( "None" ),
	link to original data table( 0 ),
	statistics column name format( "column" )
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 05 Sep 2020 02:07:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Concatenating-Merging-Updating-Multiple-Data-Tables-from-a-loop/m-p/301231#M55936</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-09-05T02:07:44Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating/Merging/Updating  Multiple Data Tables from a loop  into one</title>
      <link>https://community.jmp.com/t5/Discussions/Concatenating-Merging-Updating-Multiple-Data-Tables-from-a-loop/m-p/301252#M55939</link>
      <description />
      <pubDate>Sat, 05 Sep 2020 04:35:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Concatenating-Merging-Updating-Multiple-Data-Tables-from-a-loop/m-p/301252#M55939</guid>
      <dc:creator>tnodd</dc:creator>
      <dc:date>2020-09-05T04:35:22Z</dc:date>
    </item>
  </channel>
</rss>

