<?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: Setting multiple rows in a single column to a single value in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Setting-multiple-rows-in-a-single-column-to-a-single-value/m-p/663743#M85218</link>
    <description>&lt;P&gt;Data table substripting is sooo cool!&lt;BR /&gt;&lt;BR /&gt;why the associative array?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
myMatrix= dt&amp;lt;&amp;lt; getrowswhere(age==12);
dt[myMatrix,{age}]=999&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 29 Jul 2023 20:11:39 GMT</pubDate>
    <dc:creator>hogi</dc:creator>
    <dc:date>2023-07-29T20:11:39Z</dc:date>
    <item>
      <title>Setting multiple rows in a single column to a single value</title>
      <link>https://community.jmp.com/t5/Discussions/Setting-multiple-rows-in-a-single-column-to-a-single-value/m-p/663654#M85208</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Noob question...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a column with a unique identifier (UID) for certain types objects, for instance {'cats', 'dogs', 'birds'}. Each UID has multiple rows associated with it, which I have captured in an associative array.&lt;/P&gt;&lt;P&gt;Example: aa = { 'cats' =&amp;gt; [1, 2, 3], 'dogs' =&amp;gt; [4, 5, 6], 'birds' =&amp;gt; [7, 8, 9] }&lt;/P&gt;&lt;P&gt;For each UID, all rows associated, I need to set a different column (col2) to a single value.&lt;/P&gt;&lt;P&gt;For example: For UID 'cats', rows 1, 2 &amp;amp; 3, in col2, need to be set to 'likes napping'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;I know of the &amp;lt;&amp;lt; Set all values function, but that copies a single value for all rows in a column.&lt;/LI&gt;&lt;LI&gt;If I use dt:col 2[ aa[ 'cats' ] ] = 'likes napping', a L-value error will occur, which informs me I need a matrix of values equal to the number rows, so each row can be assigned that value.&lt;/LI&gt;&lt;LI&gt;Or, I can use a for loop nested in a for loop to assign values where I need.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This all seems clunky though. There must be a better way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here are the 2 associative arrays:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;{ UID =&amp;gt; [rows] }&lt;/LI&gt;&lt;LI&gt;{ UID =&amp;gt; value }&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="StarfruitBob_0-1690582940495.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/55447i13194FD7DE3CED68/image-size/medium?v=v2&amp;amp;px=400" role="button" title="StarfruitBob_0-1690582940495.png" alt="StarfruitBob_0-1690582940495.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 22:26:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Setting-multiple-rows-in-a-single-column-to-a-single-value/m-p/663654#M85208</guid>
      <dc:creator>StarfruitBob</dc:creator>
      <dc:date>2023-07-28T22:26:33Z</dc:date>
    </item>
    <item>
      <title>Re: Setting multiple rows in a single column to a single value</title>
      <link>https://community.jmp.com/t5/Discussions/Setting-multiple-rows-in-a-single-column-to-a-single-value/m-p/663672#M85209</link>
      <description>&lt;P&gt;When making this post, I forgot to add another possibility. Note: this dataset has a lot of rows.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// This completely removes the need to store rows in an AA, but takes a decent amount of time
for( i = 1, N rows( dt ), i++,
    row_UID = dt:UID[i];
    dt:col2[i] = aa_value[row_UID];
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Jul 2023 23:04:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Setting-multiple-rows-in-a-single-column-to-a-single-value/m-p/663672#M85209</guid>
      <dc:creator>StarfruitBob</dc:creator>
      <dc:date>2023-07-28T23:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: Setting multiple rows in a single column to a single value</title>
      <link>https://community.jmp.com/t5/Discussions/Setting-multiple-rows-in-a-single-column-to-a-single-value/m-p/663681#M85210</link>
      <description>&lt;P&gt;Use data table indexing like this&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="capture.png" style="width: 781px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/55448i77A38E956E22AEED/image-size/large?v=v2&amp;amp;px=999" role="button" title="capture.png" alt="capture.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-MESSAGE title="Data table subscripting" uid="21013" url="https://community.jmp.com/t5/Uncharted/Data-table-subscripting/m-p/21013#U21013" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-blog-thread lia-fa-icon lia-fa-blog lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 29 Jul 2023 01:44:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Setting-multiple-rows-in-a-single-column-to-a-single-value/m-p/663681#M85210</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2023-07-29T01:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: Setting multiple rows in a single column to a single value</title>
      <link>https://community.jmp.com/t5/Discussions/Setting-multiple-rows-in-a-single-column-to-a-single-value/m-p/663683#M85211</link>
      <description>&lt;P&gt;I would use the table manipulation capabilities of JMP for this operation&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
animals = {"cats", "dogs", "birds"};
dt = New Table( "lots of animals",
	add rows( 100 ),
	New Column( "UID",
		character,
		set each value( animals[Random Integer( 1, 3 )] )
	)
);

// Build the attribute table
dtLookup = new table("Lookup",
    add rows(3),
	new column("UID", character,
		values({"cats", "dogs", "birds"})
	),
	new column("col2", character,
		values({"likes napping","likes frisbee","likes cracker"})
	)
);

// Update the table to expand all values into matching rows
Data Table( "lots of animals" ) &amp;lt;&amp;lt; Update(
	With( Data Table( "Lookup" ) ),
	Match Columns( :UID = :UID )
);

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1690595401826.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/55449iA3F4A8DC3E6C95EE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_0-1690595401826.png" alt="txnelson_0-1690595401826.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 29 Jul 2023 01:50:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Setting-multiple-rows-in-a-single-column-to-a-single-value/m-p/663683#M85211</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2023-07-29T01:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: Setting multiple rows in a single column to a single value</title>
      <link>https://community.jmp.com/t5/Discussions/Setting-multiple-rows-in-a-single-column-to-a-single-value/m-p/663743#M85218</link>
      <description>&lt;P&gt;Data table substripting is sooo cool!&lt;BR /&gt;&lt;BR /&gt;why the associative array?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
myMatrix= dt&amp;lt;&amp;lt; getrowswhere(age==12);
dt[myMatrix,{age}]=999&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 29 Jul 2023 20:11:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Setting-multiple-rows-in-a-single-column-to-a-single-value/m-p/663743#M85218</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2023-07-29T20:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: Setting multiple rows in a single column to a single value</title>
      <link>https://community.jmp.com/t5/Discussions/Setting-multiple-rows-in-a-single-column-to-a-single-value/m-p/663749#M85220</link>
      <description>&lt;P&gt;Only because of the original question, but associative arrays are cool too!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 29 Jul 2023 21:18:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Setting-multiple-rows-in-a-single-column-to-a-single-value/m-p/663749#M85220</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2023-07-29T21:18:45Z</dc:date>
    </item>
    <item>
      <title>Re: Setting multiple rows in a single column to a single value</title>
      <link>https://community.jmp.com/t5/Discussions/Setting-multiple-rows-in-a-single-column-to-a-single-value/m-p/664425#M85278</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/982"&gt;@Craige_Hales&lt;/a&gt;, there's a thread somewhere on this site that has this trick for subscripting. I should probably bookmark it because of tricks like this!&amp;nbsp; Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2023 15:21:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Setting-multiple-rows-in-a-single-column-to-a-single-value/m-p/664425#M85278</guid>
      <dc:creator>StarfruitBob</dc:creator>
      <dc:date>2023-08-01T15:21:54Z</dc:date>
    </item>
    <item>
      <title>Re: Setting multiple rows in a single column to a single value</title>
      <link>https://community.jmp.com/t5/Discussions/Setting-multiple-rows-in-a-single-column-to-a-single-value/m-p/664444#M85283</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/982"&gt;@Craige_Hales&lt;/a&gt;, here's a link to your thread on subscripting for those who want to know more.&lt;BR /&gt;&lt;BR /&gt;PS - these tricks can save you a bunch of time! It's 100% worth the read!&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://community.jmp.com/t5/Uncharted/Data-table-subscripting/ba-p/21013" target="_blank"&gt;https://community.jmp.com/t5/Uncharted/Data-table-subscripting/ba-p/21013&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2023 15:54:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Setting-multiple-rows-in-a-single-column-to-a-single-value/m-p/664444#M85283</guid>
      <dc:creator>StarfruitBob</dc:creator>
      <dc:date>2023-08-01T15:54:18Z</dc:date>
    </item>
  </channel>
</rss>

