<?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: Concatenate selected row from multiple subsetted data tables into 1 new data table in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Concatenate-selected-row-from-multiple-subsetted-data-tables/m-p/398329#M64931</link>
    <description>&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;It works perfectly&lt;/P&gt;</description>
    <pubDate>Mon, 05 Jul 2021 12:06:43 GMT</pubDate>
    <dc:creator>bzanos</dc:creator>
    <dc:date>2021-07-05T12:06:43Z</dc:date>
    <item>
      <title>Concatenate selected row from multiple subsetted data tables into 1 new data table</title>
      <link>https://community.jmp.com/t5/Discussions/Concatenate-selected-row-from-multiple-subsetted-data-tables/m-p/398306#M64927</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;I have a data set(as example, Big Class) that contains all the data. I subset the data by age and select first row of each &lt;BR /&gt;subsetted data table. Then, I subset it again so that I can do concatenation of the selected row data into new table.  &lt;BR /&gt;&lt;BR /&gt;I notice that there is additional data (unwanted data ) concatenated in the new table (highlighted in red rectangular). &lt;BR /&gt;I am not sure what is the problem of my script. &lt;BR /&gt;I attach my script in below.&lt;BR /&gt;&lt;SPAN&gt;I really appreciate if anyone could help me to fix this issue.&lt;/SPAN&gt;&lt;BR /&gt;   &lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Open Big Class data table
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

//Subset the data table by age
listDT = dt &amp;lt;&amp;lt; Subset(
	By( :age ),
	All rows,
	Selected columns only( 0 ),
	columns( :name, :sex, :height, :weight )
);

//Select first row of each subset data table 
For( i = 1, i &amp;lt;= N Items( listDT ), i++,
      
    listDT[i] &amp;lt;&amp;lt; Select Rows( {1} );
    listDT[i] &amp;lt;&amp;lt; Subset("");
    
    Close(listDT[i],"No Save"); 
    Close(dt,"No Save"); 

);

// Create Tables list
Tables = {};
For( i = 1, i &amp;lt;= N Table(), i++,
	Insert Into( Tables, Data Table( i ) &amp;lt;&amp;lt; get name );
);

//Create new table
New Table("FirstRowData");

// Run the concatenations
For( i = 1, i &amp;lt;= N Items( Tables ), i++,
	 Data Table( "FirstRowData" ) &amp;lt;&amp;lt; Concatenate(
		Data Table( Tables[i] ),
		append to first table(1)
	);
	Close( Data Table( Tables[i] ), No Save );
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 19:51:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Concatenate-selected-row-from-multiple-subsetted-data-tables/m-p/398306#M64927</guid>
      <dc:creator>bzanos</dc:creator>
      <dc:date>2023-06-09T19:51:37Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate selected row from multiple subsetted data tables into 1 new data table</title>
      <link>https://community.jmp.com/t5/Discussions/Concatenate-selected-row-from-multiple-subsetted-data-tables/m-p/398328#M64930</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The issue here seems to be the table variables that were created for each subset.&amp;nbsp; Table variables with the same name ("age") were then getting added as columns with each concatenation.&amp;nbsp; See script below, and notice the For-loop added to delete the table variables.&amp;nbsp; Does this resolve the issue for you?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Open Big Class data table
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

//Subset the data table by age
listDT = dt &amp;lt;&amp;lt; Subset(
	By( :age ),
	All rows,
	Selected columns only( 0 ),
	columns( :name, :sex, :height, :weight )
);

//Select first row of each subset data table 
For( i = 1, i &amp;lt;= N Items( listDT ), i++,
      
    listDT[i] &amp;lt;&amp;lt; Select Rows( {1} );
    listDT[i] &amp;lt;&amp;lt; Subset("");
    
    Close(listDT[i],"No Save"); 
    Close(dt,"No Save"); 

);

// Create Tables list
Tables = {};
For( i = 1, i &amp;lt;= N Table(), i++,
	Insert Into( Tables, Data Table( i ) &amp;lt;&amp;lt; get name );
);

//Delete table variables
For( i = 1, i &amp;lt;= N Table(), i++,
	Data Table(Tables[i]) &amp;lt;&amp;lt; Delete Table Variable("age");
);

//Create new table
New Table("FirstRowData");

// Run the concatenations
For( i = 1, i &amp;lt;= N Items( Tables ), i++,
	 Data Table( "FirstRowData" ) &amp;lt;&amp;lt; Concatenate(
		Data Table( Tables[i] ),
		append to first table(1)
	);
	Close( Data Table( Tables[i] ), No Save );
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Jul 2021 11:03:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Concatenate-selected-row-from-multiple-subsetted-data-tables/m-p/398328#M64930</guid>
      <dc:creator>HadleyMyers</dc:creator>
      <dc:date>2021-07-05T11:03:58Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate selected row from multiple subsetted data tables into 1 new data table</title>
      <link>https://community.jmp.com/t5/Discussions/Concatenate-selected-row-from-multiple-subsetted-data-tables/m-p/398329#M64931</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;It works perfectly&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jul 2021 12:06:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Concatenate-selected-row-from-multiple-subsetted-data-tables/m-p/398329#M64931</guid>
      <dc:creator>bzanos</dc:creator>
      <dc:date>2021-07-05T12:06:43Z</dc:date>
    </item>
  </channel>
</rss>

