<?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: What's the best and more efficient method to map / define one variable based on three variables in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/What-s-the-best-and-more-efficient-method-to-map-define-one/m-p/979325#M46292</link>
    <description>&lt;P&gt;I think you need to provide a better description (an example) of what you're trying to do.&lt;/P&gt;</description>
    <pubDate>Fri, 21 Nov 2025 17:22:17 GMT</pubDate>
    <dc:creator>quickbluefish</dc:creator>
    <dc:date>2025-11-21T17:22:17Z</dc:date>
    <item>
      <title>What's the best and more efficient method to map / define one variable based on three variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/What-s-the-best-and-more-efficient-method-to-map-define-one/m-p/979316#M46291</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Make it simple.&lt;/P&gt;
&lt;P&gt;Let's say that I want to define one variable (ex: var4) based on three variables (ex: var1, var2, and var3), considering that based on the various combinaison of var1 var2 and var3, var4 could take many different values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first approach that I have in mind will be the if and condition ex:&lt;/P&gt;
&lt;P&gt;if var1 eq something and var2 eq something else and var3 eq something then var4=specific_value&lt;/P&gt;
&lt;P&gt;and so on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is also the proc format but I dont know how to define / map a new variable based on three variables.&lt;/P&gt;
&lt;P&gt;Which approach is the more efficient&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Nov 2025 16:42:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/What-s-the-best-and-more-efficient-method-to-map-define-one/m-p/979316#M46291</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2025-11-21T16:42:37Z</dc:date>
    </item>
    <item>
      <title>Re: What's the best and more efficient method to map / define one variable based on three variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/What-s-the-best-and-more-efficient-method-to-map-define-one/m-p/979325#M46292</link>
      <description>&lt;P&gt;I think you need to provide a better description (an example) of what you're trying to do.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Nov 2025 17:22:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/What-s-the-best-and-more-efficient-method-to-map-define-one/m-p/979325#M46292</guid>
      <dc:creator>quickbluefish</dc:creator>
      <dc:date>2025-11-21T17:22:17Z</dc:date>
    </item>
    <item>
      <title>Re: What's the best and more efficient method to map / define one variable based on three variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/What-s-the-best-and-more-efficient-method-to-map-define-one/m-p/979332#M46293</link>
      <description>&lt;P&gt;As you say, you can use PROC FORMAT to map one value to another.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once I had a problem where I needed to map three values into another value.&amp;nbsp; I started to build a new variable that would have the three values concatenated, and was going to build a format to map the concatenated value to my target value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then I remembered that SAS has hash tables.&amp;nbsp; You can define a hash table that has 3 key values, and use that as a lookup.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As to whether a hash table is "best" or "more efficient", it really depends on your use case.&amp;nbsp; There are lots of ways to do a lookup in SAS.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Nov 2025 17:58:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/What-s-the-best-and-more-efficient-method-to-map-define-one/m-p/979332#M46293</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2025-11-21T17:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: What's the best and more efficient method to map / define one variable based on three variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/What-s-the-best-and-more-efficient-method-to-map-define-one/m-p/979366#M46294</link>
      <description>Check GRAYCODE() function:&lt;BR /&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p1myrepjl958iin1ikhv6515cgp4.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p1myrepjl958iin1ikhv6515cgp4.htm&lt;/A&gt;</description>
      <pubDate>Sat, 22 Nov 2025 07:16:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/What-s-the-best-and-more-efficient-method-to-map-define-one/m-p/979366#M46294</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-11-22T07:16:25Z</dc:date>
    </item>
    <item>
      <title>Re: What's the best and more efficient method to map / define one variable based on three variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/What-s-the-best-and-more-efficient-method-to-map-define-one/m-p/979398#M46295</link>
      <description>&lt;P&gt;If you want to do equality tests then a hash object is probably the simplest, as long as the number of possible values is small. Create a "truth" or "lookup" table&amp;nbsp; with all of the possible values.&lt;/P&gt;
&lt;P&gt;So if VAR1 to VAR3 could each have only two possible values then your LOOKUP table will have 8 observations.&amp;nbsp; So something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data lookup;
  input var1 :$1. var2 var3 var4 :$8.;
cards;
A 1 1 1
A 1 1 2
A 2 1 3
A 2 2 4
B 1 1 5
B 1 2 6
B 2 1 7
B 2 2 8
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then you can load that into a HASH and use that to add VAR4 to your existing dataset (let's call it HAVE) and create a new dataset (let's call it WANT).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have lookup(keep=var4 obs=0);
  if _n_=1 then do;
    declare hash h(dataset:'lookup');
    h.definekey('var1','var2','var3');
    h.definedata('var4');
    h.definedone();
  end;
  if h.find() then call missing(var4);
run;
  &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Nov 2025 03:53:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/What-s-the-best-and-more-efficient-method-to-map-define-one/m-p/979398#M46295</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-11-24T03:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: What's the best and more efficient method to map / define one variable based on three variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/What-s-the-best-and-more-efficient-method-to-map-define-one/m-p/979577#M46297</link>
      <description>&lt;P&gt;Can you please explain a litle bit more the hash approac and how does it works ?&lt;/P&gt;</description>
      <pubDate>Tue, 25 Nov 2025 20:08:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/What-s-the-best-and-more-efficient-method-to-map-define-one/m-p/979577#M46297</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2025-11-25T20:08:11Z</dc:date>
    </item>
    <item>
      <title>Re: What's the best and more efficient method to map / define one variable based on three variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/What-s-the-best-and-more-efficient-method-to-map-define-one/m-p/979582#M46298</link>
      <description>&lt;P&gt;I strongly encourage you to read&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lecompobjref/n1ieochmz5vlm9n14zy0qnp3syvm.htm" target="_blank" rel="noopener"&gt;Using the Hash Object to Store and Retrieve Data&lt;/A&gt;&amp;nbsp;and come back with any further questions you have that need clarification.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Nov 2025 22:01:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/What-s-the-best-and-more-efficient-method-to-map-define-one/m-p/979582#M46298</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2025-11-25T22:01:40Z</dc:date>
    </item>
  </channel>
</rss>

