<?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 write macro for resolve in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-write-macro-for-resolve/m-p/577778#M75538</link>
    <description>&lt;P&gt;I would agree that this level of complexity probably needs to be fixed earlier in the process.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try doing it piece by piece to see how to get there.&amp;nbsp; For example you could start with just getting the value of macro variable I resolved.&lt;/P&gt;
&lt;PRE&gt;776   %PUT ZONE_&amp;amp;I._STATE_&amp;amp;I.;
ZONE_1_STATE_1&lt;/PRE&gt;
&lt;P&gt;Now you want to have the ZONE_1 part resolved.&amp;nbsp; So add a double &amp;amp;&amp;amp;. Make sure to add another period so it doesn't try to resolve ZONE_1_STATE_1 instead.&lt;/P&gt;
&lt;PRE&gt;777   %PUT &amp;amp;&amp;amp;ZONE_&amp;amp;I.._STATE_&amp;amp;I.;
SOUTH_STATE_1&lt;/PRE&gt;
&lt;P&gt;So now you have the name of the macro variable you want to resolve. So again you need to add &amp;amp;&amp;amp;, but since you already are using that trick once to get ZONE_1 to resolve you need to double each of the new &amp;amp;'s.&lt;/P&gt;
&lt;PRE&gt;778   %PUT &amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;ZONE_&amp;amp;I.._STATE_&amp;amp;I.;
DL
&lt;/PRE&gt;
&lt;P&gt;But it is probably easier to just build up the name into a new macro variable and then use triple &amp;amp; to show the value of variable whose name is in a variable.&lt;/P&gt;
&lt;P&gt;So make ZONE_1&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let mvar=zone_&amp;amp;i;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then get the value of ZONE_1.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let mvar=&amp;amp;&amp;amp;&amp;amp;mvar;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then tack on STATE_1.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let mvar=&amp;amp;mvar._state_&amp;amp;i;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now use the value of MVAR as the NAME of the macro variable you want to display.&lt;/P&gt;
&lt;PRE&gt;785   %put &amp;amp;=mvar;
MVAR=SOUTH_state_1
786   %put &amp;amp;&amp;amp;&amp;amp;mvar;
DL&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Jul 2019 15:04:59 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-07-30T15:04:59Z</dc:date>
    <item>
      <title>How write macro for resolve</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-write-macro-for-resolve/m-p/577613#M75522</link>
      <description>%let I=1;&lt;BR /&gt;%let zone_1=SOUTH;&lt;BR /&gt;&lt;BR /&gt;%let SOUTH_STATE_1=DL;&lt;BR /&gt;&lt;BR /&gt;%PUT &amp;amp;&amp;amp; ZONE_&amp;amp;I_STATE_1;&lt;BR /&gt;&lt;BR /&gt;I am trying to get the 'DL' value but the macro not resolving.&lt;BR /&gt;How to write % put to get value 'DL'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 30 Jul 2019 06:14:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-write-macro-for-resolve/m-p/577613#M75522</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2019-07-30T06:14:24Z</dc:date>
    </item>
    <item>
      <title>Re: How write macro for resolve</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-write-macro-for-resolve/m-p/577627#M75524</link>
      <description>&lt;P&gt;Simple answer: don't. If any other coder has to maintain such code, you're dead. Even if you emigrated to another continent. They'll track you down just to make an example of you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just to show you what kind of abomination results out of such mindless abuse of the macro preprocessor, here's the solution:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let I=1;
%let zone_1=SOUTH;

%let SOUTH_STATE_1=DL;
%let third_part=_state_1;

%put &amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;zone_&amp;amp;i.&amp;amp;&amp;amp;third_part.;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log excerpt:&lt;/P&gt;
&lt;PRE&gt;33         %put &amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;zone_&amp;amp;i.&amp;amp;&amp;amp;third_part.;
DL
&lt;/PRE&gt;
&lt;P&gt;Note that I had to make up another macro variable to satisfy the necessary levels of indirection.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2019 07:39:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-write-macro-for-resolve/m-p/577627#M75524</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-07-30T07:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: How write macro for resolve</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-write-macro-for-resolve/m-p/577650#M75525</link>
      <description>How to do without third_part&lt;BR /&gt;</description>
      <pubDate>Tue, 30 Jul 2019 09:49:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-write-macro-for-resolve/m-p/577650#M75525</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2019-07-30T09:49:43Z</dc:date>
    </item>
    <item>
      <title>Re: How write macro for resolve</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-write-macro-for-resolve/m-p/577657#M75526</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/209685"&gt;@thanikondharish&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;How to do without third_part&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No idea.&lt;/P&gt;
&lt;P&gt;But you can try to do it in a data step (which I recommend for complicated string operations anyway):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let I=1;
%let zone_1=SOUTH;

%let SOUTH_STATE_1=DL;

data _null_;
name1 = resolve('&amp;amp;' !! resolve('&amp;amp;zone_' !! "&amp;amp;i") !! '_state_1');
call symputx('result',name1);
run;

%put &amp;amp;result;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log excerpt:&lt;/P&gt;
&lt;PRE&gt;37         %put &amp;amp;result;
DL
&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Jul 2019 10:55:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-write-macro-for-resolve/m-p/577657#M75526</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-07-30T10:55:30Z</dc:date>
    </item>
    <item>
      <title>Re: How write macro for resolve</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-write-macro-for-resolve/m-p/577759#M75537</link>
      <description>&lt;P&gt;Try it this way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let I=1;
%let zone_1=SOUTH;

%let SOUTH_STATE_1=DL;

%put &amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;zone_&amp;amp;i.._state_1;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Jul 2019 14:36:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-write-macro-for-resolve/m-p/577759#M75537</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-07-30T14:36:21Z</dc:date>
    </item>
    <item>
      <title>Re: How write macro for resolve</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-write-macro-for-resolve/m-p/577778#M75538</link>
      <description>&lt;P&gt;I would agree that this level of complexity probably needs to be fixed earlier in the process.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try doing it piece by piece to see how to get there.&amp;nbsp; For example you could start with just getting the value of macro variable I resolved.&lt;/P&gt;
&lt;PRE&gt;776   %PUT ZONE_&amp;amp;I._STATE_&amp;amp;I.;
ZONE_1_STATE_1&lt;/PRE&gt;
&lt;P&gt;Now you want to have the ZONE_1 part resolved.&amp;nbsp; So add a double &amp;amp;&amp;amp;. Make sure to add another period so it doesn't try to resolve ZONE_1_STATE_1 instead.&lt;/P&gt;
&lt;PRE&gt;777   %PUT &amp;amp;&amp;amp;ZONE_&amp;amp;I.._STATE_&amp;amp;I.;
SOUTH_STATE_1&lt;/PRE&gt;
&lt;P&gt;So now you have the name of the macro variable you want to resolve. So again you need to add &amp;amp;&amp;amp;, but since you already are using that trick once to get ZONE_1 to resolve you need to double each of the new &amp;amp;'s.&lt;/P&gt;
&lt;PRE&gt;778   %PUT &amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;ZONE_&amp;amp;I.._STATE_&amp;amp;I.;
DL
&lt;/PRE&gt;
&lt;P&gt;But it is probably easier to just build up the name into a new macro variable and then use triple &amp;amp; to show the value of variable whose name is in a variable.&lt;/P&gt;
&lt;P&gt;So make ZONE_1&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let mvar=zone_&amp;amp;i;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then get the value of ZONE_1.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let mvar=&amp;amp;&amp;amp;&amp;amp;mvar;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then tack on STATE_1.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let mvar=&amp;amp;mvar._state_&amp;amp;i;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now use the value of MVAR as the NAME of the macro variable you want to display.&lt;/P&gt;
&lt;PRE&gt;785   %put &amp;amp;=mvar;
MVAR=SOUTH_state_1
786   %put &amp;amp;&amp;amp;&amp;amp;mvar;
DL&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2019 15:04:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-write-macro-for-resolve/m-p/577778#M75538</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-30T15:04:59Z</dc:date>
    </item>
  </channel>
</rss>

