<?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: Create macro variable based on value of other macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-variable-based-on-value-of-other-macro-variable/m-p/644927#M192725</link>
    <description>&lt;P&gt;There can be a number of nuances depending on where you are placing this code but basically:&lt;/P&gt;
&lt;PRE&gt;%If &amp;amp;legal_entity_cd = EXXP %then %let entity_id =12345;
%If &amp;amp;legal_entity_cd = EXPP %then %let entity_id =23456;
%If &amp;amp;legal_entity_cd = EXXP %then %let entity_id =34567;&lt;/PRE&gt;
&lt;P&gt;Should work.&lt;/P&gt;
&lt;P&gt;Note I have to assume you did not intend to place quotes int he NAME of the variable as that is not syntactically correct. And placing quotes as part of variables is one of the ways to make macro variables hard to use consistently.&lt;/P&gt;</description>
    <pubDate>Mon, 04 May 2020 08:13:46 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-05-04T08:13:46Z</dc:date>
    <item>
      <title>Create macro variable based on value of other macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-variable-based-on-value-of-other-macro-variable/m-p/644924#M192723</link>
      <description>&lt;P&gt;I want to create one macro variable called 'entity_id' based on value of other macro variable 'legal_entity_cd'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If value of 'legal_entity_cd' resolves to 'EXXP' then I want one macro variable called 'entity_id'&amp;nbsp;and it should resolves to '12345'&lt;/P&gt;
&lt;P&gt;If value of 'legal_entity_cd' resolves to 'EXPP' then I want one macro variable called 'entity_id'&amp;nbsp;and it should resolves to '23456'&lt;/P&gt;
&lt;P&gt;If value of 'legal_entity_cd' resolves to 'EEPP' then I want one macro variable called 'entity_id'&amp;nbsp;and it should resolves to '34567'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I tackle this?&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2020 08:01:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-macro-variable-based-on-value-of-other-macro-variable/m-p/644924#M192723</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2020-05-04T08:01:34Z</dc:date>
    </item>
    <item>
      <title>Re: Create macro variable based on value of other macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-variable-based-on-value-of-other-macro-variable/m-p/644925#M192724</link>
      <description>&lt;P&gt;Please check the below code where we create the macro variables&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let EXXP= 12345;
%let legal_entity_cd=&amp;amp;exxp;
%let entity_id=&amp;amp;legal_entity_cd;

%put &amp;amp;entity_id;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 May 2020 08:04:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-macro-variable-based-on-value-of-other-macro-variable/m-p/644925#M192724</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-05-04T08:04:43Z</dc:date>
    </item>
    <item>
      <title>Re: Create macro variable based on value of other macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-variable-based-on-value-of-other-macro-variable/m-p/644927#M192725</link>
      <description>&lt;P&gt;There can be a number of nuances depending on where you are placing this code but basically:&lt;/P&gt;
&lt;PRE&gt;%If &amp;amp;legal_entity_cd = EXXP %then %let entity_id =12345;
%If &amp;amp;legal_entity_cd = EXPP %then %let entity_id =23456;
%If &amp;amp;legal_entity_cd = EXXP %then %let entity_id =34567;&lt;/PRE&gt;
&lt;P&gt;Should work.&lt;/P&gt;
&lt;P&gt;Note I have to assume you did not intend to place quotes int he NAME of the variable as that is not syntactically correct. And placing quotes as part of variables is one of the ways to make macro variables hard to use consistently.&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2020 08:13:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-macro-variable-based-on-value-of-other-macro-variable/m-p/644927#M192725</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-05-04T08:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: Create macro variable based on value of other macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-variable-based-on-value-of-other-macro-variable/m-p/644955#M192728</link>
      <description>&lt;P&gt;I would use an informat for that, seems most natural:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
  invalue ent_val
    'EXXP'=12345
    'EXPP'=23456
    'EEPP'=34567
    other=.
  ;
run;

%let entity_id=%sysfunc(input(&amp;amp;legal_entity_cd,ent_val.));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 May 2020 11:28:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-macro-variable-based-on-value-of-other-macro-variable/m-p/644955#M192728</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2020-05-04T11:28:28Z</dc:date>
    </item>
  </channel>
</rss>

