<?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 Fill column with values based on another column with keys and associative array in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Fill-column-with-values-based-on-another-column-with-keys-and/m-p/661850#M85064</link>
    <description>&lt;P&gt;I did a quick search and couldn't find a solution. I solved it in a pretty complex way some time ago, but was wondering if there is an easier way.&lt;/P&gt;&lt;P&gt;Problem: I have an associative array of a form:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;assarr = ["AA" =&amp;gt; "AAA", "BB" =&amp;gt; "BBB", =&amp;gt; "CCC" ];&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I have a column "A" that has either "AA", "BB", or something else.&lt;/P&gt;&lt;P&gt;I need to fill column "B" with values based on the associative array and column "A". i.e. for a row with "A" having "AA", "B" should be "AAA" and so on. If "A" has values not in the array, "B" should get the default "CCC".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Based on the fact how easy it is to create an associative array from two columns, there should be equally easy way to fill column based on associative array and another column with keys.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;&lt;P&gt;M.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 24 Jul 2023 18:07:53 GMT</pubDate>
    <dc:creator>miguello</dc:creator>
    <dc:date>2023-07-24T18:07:53Z</dc:date>
    <item>
      <title>Fill column with values based on another column with keys and associative array</title>
      <link>https://community.jmp.com/t5/Discussions/Fill-column-with-values-based-on-another-column-with-keys-and/m-p/661850#M85064</link>
      <description>&lt;P&gt;I did a quick search and couldn't find a solution. I solved it in a pretty complex way some time ago, but was wondering if there is an easier way.&lt;/P&gt;&lt;P&gt;Problem: I have an associative array of a form:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;assarr = ["AA" =&amp;gt; "AAA", "BB" =&amp;gt; "BBB", =&amp;gt; "CCC" ];&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I have a column "A" that has either "AA", "BB", or something else.&lt;/P&gt;&lt;P&gt;I need to fill column "B" with values based on the associative array and column "A". i.e. for a row with "A" having "AA", "B" should be "AAA" and so on. If "A" has values not in the array, "B" should get the default "CCC".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Based on the fact how easy it is to create an associative array from two columns, there should be equally easy way to fill column based on associative array and another column with keys.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;&lt;P&gt;M.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2023 18:07:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Fill-column-with-values-based-on-another-column-with-keys-and/m-p/661850#M85064</guid>
      <dc:creator>miguello</dc:creator>
      <dc:date>2023-07-24T18:07:53Z</dc:date>
    </item>
    <item>
      <title>Re: Fill column with values based on another column with keys and associative array</title>
      <link>https://community.jmp.com/t5/Discussions/Fill-column-with-values-based-on-another-column-with-keys-and/m-p/661898#M85066</link>
      <description>&lt;P&gt;Do you mean something like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

aa = ["AA" =&amp;gt; "AAA", "BB" =&amp;gt; "BBB", =&amp;gt; "CCC"];

dt = New Table("Untitled",
	Add Rows(5),
	Compress File When Saved(1),
	New Column("Column 1",
		Character,
		"Nominal",
		Set Values({"AA", "BB", "aa", "C", "D"})
	)
);

wait(1);

dt &amp;lt;&amp;lt; New Column("Column 2", Character, Nominal, &amp;lt;&amp;lt; Set Each Value(
	aa[:Column 1]
));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Jul 2023 18:35:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Fill-column-with-values-based-on-another-column-with-keys-and/m-p/661898#M85066</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-07-24T18:35:05Z</dc:date>
    </item>
    <item>
      <title>Re: Fill column with values based on another column with keys and associative array</title>
      <link>https://community.jmp.com/t5/Discussions/Fill-column-with-values-based-on-another-column-with-keys-and/m-p/661921#M85067</link>
      <description>&lt;P&gt;Hmmm. Yes, this is exactly what I need. Thank you! Somehow I didn't try this rather obvious approach before.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2023 18:50:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Fill-column-with-values-based-on-another-column-with-keys-and/m-p/661921#M85067</guid>
      <dc:creator>miguello</dc:creator>
      <dc:date>2023-07-24T18:50:06Z</dc:date>
    </item>
  </channel>
</rss>

