<?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: How to add data values to a table in a for loop using Select Columns Where to make a new overall data table of target data in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-add-data-values-to-a-table-in-a-for-loop-using-Select/m-p/384406#M63478</link>
    <description>&lt;P&gt;Selecting Columns part is maybe a very small efficiency gain, but mostly it just makes the code easier to read (in my opinion).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have you tried adding debugging prints inside loops to see if there is anything to subset:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For(i = 1, i &amp;lt;= N Items(IDs), i++,
	ID = IDs[i];
	date_array = Associative Array({"date1", "date2", "date"}, {{}, {}, {}});
	For(date = date_array &amp;lt;&amp;lt; First, !Is Empty(date), date = date_array &amp;lt;&amp;lt; Next(date),		
		dt &amp;lt;&amp;lt; Select Where(:Timepoint == date);
		Show(N Items(dt &amp;lt;&amp;lt; Get Selected Rows));
		dt_ld4 &amp;lt;&amp;lt; Subset(Columns({"Timepoint", "Target Channel"}), Selected Rows, Output table name("Subset"));
	);
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I added&amp;nbsp;&lt;CODE class=" language-jsl"&gt;Show(N Items(dt &amp;lt;&amp;lt; Get Selected Rows));&lt;/CODE&gt;&amp;nbsp;which should tell you if any rows have been selected. Also I wouldn't feel comfortable using ID as variablename if you have similarly named column (it might work, not sure, but I do avoid such names just to be sure). I would replace it with currentID or something.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would think that at this point, it could maybe be easier if we had one topic in which we could try to help you solve this issue part by part.&amp;nbsp;One thing that would help us a lot would be having an example dataset. The dataset doesn't have to be large, can be anonymized or completely fake data, but it should still be realistic (column data types same, possibility to test different cases).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 12 May 2021 06:22:18 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2021-05-12T06:22:18Z</dc:date>
    <item>
      <title>How to add data values to a table in a for loop using Select Columns Where to make a new overall data table of target data</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-add-data-values-to-a-table-in-a-for-loop-using-Select/m-p/383363#M63400</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For( date = date_array &amp;lt;&amp;lt; First, !Is Empty( date ), date = date_array &amp;lt;&amp;lt; Next( date ), //looping through date_array's keys is clunky but done this way in JMP
		dt &amp;lt;&amp;lt; Select Columns( :Timepoint, :Target Channel, :Run date ), Where(:Timepoint == date);
		dt &amp;lt;&amp;lt; Subset( ( Selected Rows ), Output Table Name( "Subset" ));&lt;BR /&gt;);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I wish to add, progressively, through each iteration of a for loop, data specified by a column criterion (:Timepoint == LBCM) and combine it into a combined data table at the end, when the loop is done, and display the result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As of now it doesn't add anything anywhere; I end up with no new data table at all.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have all of this inside another for loop, as well, based off of a sample ID but I think adding that here would only overcomplicate things for now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All the other examples I have found in the JMP Community Forums are very complicated, or so they seem, building arrays of data and transferring them to data tables or things like that. I wish for the solution here to be as simple as possible. Of course, I will contribute to the conversation as replies come in, but as of now I am just flat out stuck.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help,&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:29:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-add-data-values-to-a-table-in-a-for-loop-using-Select/m-p/383363#M63400</guid>
      <dc:creator>mostarr</dc:creator>
      <dc:date>2023-06-10T23:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to add data values to a table in a for loop using Select Columns Where to make a new overall data table of target data</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-add-data-values-to-a-table-in-a-for-loop-using-Select/m-p/383396#M63403</link>
      <description>&lt;P&gt;Take a look at&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; add rows(n);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to add new rows as needed&lt;/P&gt;</description>
      <pubDate>Sat, 08 May 2021 01:20:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-add-data-values-to-a-table-in-a-for-loop-using-Select/m-p/383396#M63403</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-05-08T01:20:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to add data values to a table in a for loop using Select Columns Where to make a new overall data table of target data</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-add-data-values-to-a-table-in-a-for-loop-using-Select/m-p/383411#M63404</link>
      <description>&lt;P&gt;I'm not 100% sure what you want to do here so I'm guessing a little&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These two rows seems like there might be some issues:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; Select Columns( :Timepoint, :Target Channel, :Run date ), Where(:Timepoint == date);
dt &amp;lt;&amp;lt; Subset( ( Selected Rows ), Output Table Name( "Subset" )););&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You can combine the columns you want inside the subset command and selecting rows can be done with &amp;lt;&amp;lt; Select Where (seems like you are missing Select).&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; Select Where(:Timepoint == date);
dt &amp;lt;&amp;lt; Subset(Columns({"Timepoint", "TargetChannel"}), Selected Rows, Output table name("Subset"));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Also if you would prefer to first select the columns which you want to subset, you will have to add Selected Columns inside Subset command&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; Subset(Output table name("Subset"), Selected Rows, Selected Columns);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 08 May 2021 06:24:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-add-data-values-to-a-table-in-a-for-loop-using-Select/m-p/383411#M63404</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-05-08T06:24:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to add data values to a table in a for loop using Select Columns Where to make a new overall data table of target data</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-add-data-values-to-a-table-in-a-for-loop-using-Select/m-p/384367#M63470</link>
      <description>&lt;P&gt;Thanks for this, Jarmo. So is your code mostly an efficiency gain or a bona fide functionality gain?&lt;/P&gt;&lt;P&gt;It doesn't work outright for me, but I have to say that I have all of this in another for loop (or two):&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For( i = 1, i &amp;lt;= N Items( IDs ), i++,
	ID = IDs[i];
	date_array = Associative Array( {"date1", "date2", "date"}, {{}, {}, {}} );
	For( date = date_array &amp;lt;&amp;lt; First, !Is Empty( date ), date = date_array &amp;lt;&amp;lt; Next( date ), //looping through date_array's keys is clunky but done this way in JMP			
		dt &amp;lt;&amp;lt; Select Where(:Timepoint == date);
		dt_ld4 &amp;lt;&amp;lt; Subset(Columns({"Timepoint", "Target Channel"}), Selected Rows, Output table name("Subset"));
//...
););&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The computer seems to think quite a bit upon execution but nothing shows up on the screen. I have to note that all of this code is anonymized so there's possibility for spelling mistakes and transcription errors, as well as possibility of getting confused with earlier versions of what was written. I guess it's safe to assume approximate similarities can be made...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know if these two lines should be inside the loops or outside one of them, or if I need both loops at this point in time. I need to take a deep hard look at the script one more time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm also discussing a few separate topics regarding this bit of code in separate posts. Could someone senior let me know if that is acceptable etiquette, or if it would be preferable to prioritize the code chunk into one post and discuss the separate topics in the single post, or whether either way is alright?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Muchos Gracias,&lt;/P&gt;&lt;P&gt;Michael&lt;/P&gt;</description>
      <pubDate>Tue, 11 May 2021 19:38:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-add-data-values-to-a-table-in-a-for-loop-using-Select/m-p/384367#M63470</guid>
      <dc:creator>mostarr</dc:creator>
      <dc:date>2021-05-11T19:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to add data values to a table in a for loop using Select Columns Where to make a new overall data table of target data</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-add-data-values-to-a-table-in-a-for-loop-using-Select/m-p/384406#M63478</link>
      <description>&lt;P&gt;Selecting Columns part is maybe a very small efficiency gain, but mostly it just makes the code easier to read (in my opinion).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have you tried adding debugging prints inside loops to see if there is anything to subset:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For(i = 1, i &amp;lt;= N Items(IDs), i++,
	ID = IDs[i];
	date_array = Associative Array({"date1", "date2", "date"}, {{}, {}, {}});
	For(date = date_array &amp;lt;&amp;lt; First, !Is Empty(date), date = date_array &amp;lt;&amp;lt; Next(date),		
		dt &amp;lt;&amp;lt; Select Where(:Timepoint == date);
		Show(N Items(dt &amp;lt;&amp;lt; Get Selected Rows));
		dt_ld4 &amp;lt;&amp;lt; Subset(Columns({"Timepoint", "Target Channel"}), Selected Rows, Output table name("Subset"));
	);
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I added&amp;nbsp;&lt;CODE class=" language-jsl"&gt;Show(N Items(dt &amp;lt;&amp;lt; Get Selected Rows));&lt;/CODE&gt;&amp;nbsp;which should tell you if any rows have been selected. Also I wouldn't feel comfortable using ID as variablename if you have similarly named column (it might work, not sure, but I do avoid such names just to be sure). I would replace it with currentID or something.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would think that at this point, it could maybe be easier if we had one topic in which we could try to help you solve this issue part by part.&amp;nbsp;One thing that would help us a lot would be having an example dataset. The dataset doesn't have to be large, can be anonymized or completely fake data, but it should still be realistic (column data types same, possibility to test different cases).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 May 2021 06:22:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-add-data-values-to-a-table-in-a-for-loop-using-Select/m-p/384406#M63478</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-05-12T06:22:18Z</dc:date>
    </item>
    <item>
      <title>A</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-add-data-values-to-a-table-in-a-for-loop-using-Select/m-p/384413#M63482</link>
      <description />
      <pubDate>Wed, 12 May 2021 10:46:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-add-data-values-to-a-table-in-a-for-loop-using-Select/m-p/384413#M63482</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-05-12T10:46:31Z</dc:date>
    </item>
  </channel>
</rss>

