<?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: Macro set with CALL SYMPUTX not resolving in same step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-set-with-CALL-SYMPUTX-not-resolving-in-same-step/m-p/409799#M100138</link>
    <description>&lt;P&gt;Just to clarify further:&lt;/P&gt;
&lt;P&gt;&amp;amp;L12MODATE is resolved while the code is being fetched for compilation. call symput() executes &lt;EM&gt;after&lt;/EM&gt; compilation, when the compiled data step is run.&lt;/P&gt;
&lt;P&gt;If you want to keep values across dataset observations (and therefore data step iterations), you can use the symget() function to retrieve macro variables set with call symput() in the same data step. But before doing this, look if other methods (retained variables, hash objects, temporary arrays or the lag() function) might not do the same, and avoid the macro detour.&lt;/P&gt;</description>
    <pubDate>Thu, 02 Nov 2017 12:22:57 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2017-11-02T12:22:57Z</dc:date>
    <item>
      <title>Macro set with CALL SYMPUTX not resolving in same step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-set-with-CALL-SYMPUTX-not-resolving-in-same-step/m-p/409790#M100136</link>
      <description>&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16375i593929FC581F0748/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;FONT size="3"&gt;Got this error from this Macro:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;FONT size="3"&gt;&lt;FONT face="Arial"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;FONT size="3" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT size="3" color="#0000ff"&gt;_null_&lt;/FONT&gt;&lt;FONT size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;FONT size="3" color="#0000ff"&gt;call&lt;/FONT&gt;&lt;FONT size="3"&gt; symputx(&lt;/FONT&gt;&lt;FONT size="3" color="#800080"&gt;'L12MODATE'&lt;/FONT&gt;&lt;FONT size="3"&gt;,intnx(&lt;/FONT&gt;&lt;FONT size="3" color="#800080"&gt;'month'&lt;/FONT&gt;&lt;FONT size="3"&gt;,today(),-&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT size="3" color="#008080"&gt;12&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT size="3"&gt;,&lt;/FONT&gt;&lt;FONT size="3" color="#800080"&gt;'E'&lt;/FONT&gt;&lt;FONT size="3"&gt;));&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;FONT size="3" color="#0000ff"&gt;call&lt;/FONT&gt;&lt;FONT size="3"&gt; symputx(&lt;/FONT&gt;&lt;FONT size="3" color="#800080"&gt;'L1MODATE'&lt;/FONT&gt;&lt;FONT size="3"&gt;,intnx(&lt;/FONT&gt;&lt;FONT size="3" color="#800080"&gt;'month'&lt;/FONT&gt;&lt;FONT size="3"&gt;,today(),-&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT size="3" color="#008080"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT size="3"&gt;,&lt;/FONT&gt;&lt;FONT size="3" color="#800080"&gt;'E'&lt;/FONT&gt;&lt;FONT size="3"&gt;));&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;FONT size="3" color="#0000ff"&gt;call&lt;/FONT&gt;&lt;FONT size="3"&gt; symput(&lt;/FONT&gt;&lt;FONT size="3" color="#800080"&gt;'testADJL12M'&lt;/FONT&gt;&lt;FONT size="3"&gt;,put(&amp;amp;L12MODATE,&lt;/FONT&gt;&lt;FONT size="3" color="#008080"&gt;Monyy7.&lt;/FONT&gt;&lt;FONT size="3"&gt;));&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;FONT size="3" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Arial"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2017 12:10:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-set-with-CALL-SYMPUTX-not-resolving-in-same-step/m-p/409790#M100136</guid>
      <dc:creator>Hessa</dc:creator>
      <dc:date>2017-11-02T12:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: Macro set with CALL SYMPUTX not resolving in same step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-set-with-CALL-SYMPUTX-not-resolving-in-same-step/m-p/409794#M100137</link>
      <description>&lt;P&gt;It won't resolve in the same data step. Put it in a new data step. (Or just use the formula for &amp;amp;L12MODATE instead of &amp;amp;L12MODATE) (Or, make L12MODATE a data step variable and then you can use it wherever you want in the data step)&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2017 12:14:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-set-with-CALL-SYMPUTX-not-resolving-in-same-step/m-p/409794#M100137</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-11-02T12:14:32Z</dc:date>
    </item>
    <item>
      <title>Re: Macro set with CALL SYMPUTX not resolving in same step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-set-with-CALL-SYMPUTX-not-resolving-in-same-step/m-p/409799#M100138</link>
      <description>&lt;P&gt;Just to clarify further:&lt;/P&gt;
&lt;P&gt;&amp;amp;L12MODATE is resolved while the code is being fetched for compilation. call symput() executes &lt;EM&gt;after&lt;/EM&gt; compilation, when the compiled data step is run.&lt;/P&gt;
&lt;P&gt;If you want to keep values across dataset observations (and therefore data step iterations), you can use the symget() function to retrieve macro variables set with call symput() in the same data step. But before doing this, look if other methods (retained variables, hash objects, temporary arrays or the lag() function) might not do the same, and avoid the macro detour.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2017 12:22:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-set-with-CALL-SYMPUTX-not-resolving-in-same-step/m-p/409799#M100138</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-11-02T12:22:57Z</dc:date>
    </item>
    <item>
      <title>Re: Macro set with CALL SYMPUTX not resolving in same step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-set-with-CALL-SYMPUTX-not-resolving-in-same-step/m-p/409805#M100143</link>
      <description>&lt;P&gt;Or just do it using code:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  call symputx('L12MODATE',intnx('month',today(),-12,'E'));
  call symputx('L1MODATE',intnx('month',today(),-1,'E'));
  call symput('testADJL12M',put(intnx('month',today(),-12,'E'),Monyy7.));
run;&lt;/PRE&gt;
&lt;P&gt;Or, to add, you could just use the base SAS code you give above in your code rather than use macro variables at all.&amp;nbsp; I.e. as a programmer I know what:&lt;/P&gt;
&lt;PRE&gt;intnx('month',today(),-12,'E')&lt;/PRE&gt;
&lt;P&gt;means, however (and for the sake of a few typing characters):&lt;/P&gt;
&lt;PRE&gt;&amp;amp;L12MODATE.&lt;/PRE&gt;
&lt;P&gt;Is totally meaningless to me, and means I then have to spend further time decoding what is happening - this is what obfuscation does.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2017 12:52:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-set-with-CALL-SYMPUTX-not-resolving-in-same-step/m-p/409805#M100143</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-02T12:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: Macro set with CALL SYMPUTX not resolving in same step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-set-with-CALL-SYMPUTX-not-resolving-in-same-step/m-p/409826#M100151</link>
      <description>&lt;P&gt;You need SYMGET(N).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;27         data _null_;
28            call symputx('L12MODATE',intnx('month',today(),-12,'E'));
29            call symputx('L1MODATE',intnx('month',today(),-1,'E'));
30            call symputx('testADJL12M',put(symgetn('L12MODATE'),Monyy7.));
31            run;

    

32         %put &amp;amp;=L12modate &amp;amp;=testADJL12M;
L12MODATE=20788 TESTADJL12M=NOV2016&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Nov 2017 14:07:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-set-with-CALL-SYMPUTX-not-resolving-in-same-step/m-p/409826#M100151</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2017-11-02T14:07:40Z</dc:date>
    </item>
    <item>
      <title>Re: Macro set with CALL SYMPUTX not resolving in same step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-set-with-CALL-SYMPUTX-not-resolving-in-same-step/m-p/409997#M100210</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;You need SYMGET(N).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;27         data _null_;
28            call symputx('L12MODATE',intnx('month',today(),-12,'E'));
29            call symputx('L1MODATE',intnx('month',today(),-1,'E'));
30            call symputx('testADJL12M',put(symgetn('L12MODATE'),Monyy7.));
31            run;

    

32         %put &amp;amp;=L12modate &amp;amp;=testADJL12M;
L12MODATE=20788 TESTADJL12M=NOV2016&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I'm sorry, all this symget or symgetn is completely unnecessary and overcomplicates things.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _null_;
    l12modate=intnx('month',today(),-12,'E');
    call symputx('L12MODATE',l12modate);
    call symputx('L1MODATE',intnx('month',today(),-1,'E'));
    call symputx('testADJL12M',put(l12modate,Monyy7.));
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2017 20:07:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-set-with-CALL-SYMPUTX-not-resolving-in-same-step/m-p/409997#M100210</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-11-02T20:07:26Z</dc:date>
    </item>
  </channel>
</rss>

