<?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: call symput in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/551243#M153149</link>
    <description>&lt;P&gt;If you were writing the code using macro language functions, you would get the correct result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In a DATA step, however,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"s"&amp;nbsp; =&amp;nbsp; "same"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;s = use the value of the DATA step variable named S to indicate whether you want the beginning, same, or ending date&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add quotes around the S, and all will be well.&lt;/P&gt;</description>
    <pubDate>Mon, 15 Apr 2019 20:17:25 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2019-04-15T20:17:25Z</dc:date>
    <item>
      <title>call symput</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/551239#M153145</link>
      <description>&lt;P&gt;Hello&lt;BR /&gt;Why the result in the following example giving a null result .&lt;BR /&gt;I expect to get the value of 15JAN2019 (because today is 15APR2019)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
call symput('x1',intnx('month',today(),-3,s)); /* 01JAN2019*/
RUN;
%put &amp;amp;x1;
 &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Apr 2019 20:13:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/551239#M153145</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2019-04-15T20:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: call symput</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/551241#M153147</link>
      <description>&lt;P&gt;enclose s in quotes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;'s'&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;BR /&gt;1343 call symput('x1',put(intnx('month',today(),-3,'s'),date9.)); /* 01JAN2019*/&lt;BR /&gt;1344 RUN;&lt;/P&gt;
&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;SYMBOLGEN: Macro variable X1 resolves to 15JAN2019&lt;BR /&gt;1345 %put &amp;amp;x1;&lt;BR /&gt;15JAN2019&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2019 20:15:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/551241#M153147</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-15T20:15:53Z</dc:date>
    </item>
    <item>
      <title>Re: call symput</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/551242#M153148</link>
      <description>&lt;P&gt;Or if you want the date to revert to 1st of the month, &lt;STRONG&gt;remove 's'&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Like&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
call symput('x1',put(intnx('month',today(),-3),date9.)); /* 01JAN2019*/
RUN;
%put &amp;amp;x1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;6 data _null_;&lt;BR /&gt;1347 call symput('x1',put(intnx('month',today(),-3),date9.)); /* 01JAN2019*/&lt;BR /&gt;1348 RUN;&lt;/P&gt;
&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;SYMBOLGEN: Macro variable X1 resolves to 01JAN2019&lt;BR /&gt;1349 %put &amp;amp;x1;&lt;BR /&gt;01JAN2019&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2019 20:16:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/551242#M153148</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-15T20:16:50Z</dc:date>
    </item>
    <item>
      <title>Re: call symput</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/551243#M153149</link>
      <description>&lt;P&gt;If you were writing the code using macro language functions, you would get the correct result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In a DATA step, however,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"s"&amp;nbsp; =&amp;nbsp; "same"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;s = use the value of the DATA step variable named S to indicate whether you want the beginning, same, or ending date&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add quotes around the S, and all will be well.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2019 20:17:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/551243#M153149</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-04-15T20:17:25Z</dc:date>
    </item>
    <item>
      <title>Re: call symput</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/551259#M153154</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello&lt;BR /&gt;Why the result in the following example giving a null result .&lt;BR /&gt;I expect to get the value of 15JAN2019 (because today is 15APR2019)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
call symput('x1',intnx('month',today(),-3,s)); /* 01JAN2019*/
RUN;
%put &amp;amp;x1;
 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;For all of the reasons that SAS states in the LOG.&lt;/P&gt;
&lt;PRE&gt;1226  data _null_;
1227  call symput('x1',intnx('month',today(),-3,s)); /* 01JAN2019*/
1228  RUN;

NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
      1227:18   1227:43
NOTE: Variable s is uninitialized.
NOTE: Argument 4 to function INTNX('month',21654,-3,'           .') at line 1227 column 18 is invalid.
s=. _ERROR_=1 _N_=1
NOTE: Mathematical operations could not be performed at the following places. The results of the
      operations have been set to missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      1 at 1227:18
NOTE: DATA statement used (Total process time):
      real time           0.24 seconds
      cpu time            0.03 seconds


1229  %put &amp;amp;x1;
.
1230  %put |&amp;amp;x1|;
|           .|
&lt;/PRE&gt;
&lt;P&gt;You did not create the variable S that you used in your INTNX() function call so SAS created it for you as a numeric varaible. Since that position in the function call needs a string SAS converted the missing value of S to a string using the BEST12. format.&amp;nbsp; So then INTNX() function complained when the value of the last parameter was eleven spaces followed by a period, as that was not one of the supported values.&amp;nbsp; So INTNX() returned missing.&amp;nbsp; Now the second argument to CALL SYMPUT needs to be a string so SAS again had to convert that missing numeric value into a string to write into the macro variable X1.&amp;nbsp; If you look closely you will see that X1 actually has the same eleven spaces plus a period that INTNX() complained about because that is what BEST12 format produces for missing values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you add quotes around the letter S then SAS will know you mean the string with a value of S instead of a variable named S.&lt;/P&gt;
&lt;P&gt;If you use CALL SYMPUTX() then it will convert the number to a string automatically for you without the note.&lt;/P&gt;
&lt;P&gt;If you add a call to the PUT() (or PUTN() ) function then you can set the macro variable to the FORMATTED value.&lt;/P&gt;
&lt;PRE&gt;1231  data _null_;
1232  call symputX('x1',put(intnx('month',today(),-3,'s'),date9.));
1233  RUN;

NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


1234  %put &amp;amp;x1;
15JAN2019
1235  %put |&amp;amp;x1|;
|15JAN2019|
&lt;/PRE&gt;
&lt;P&gt;Or you could skip the data step do the whole thing in macro logic.&amp;nbsp; In that case you don't need use quotes since in macro code you use &amp;amp; to let it know when you are referencing a macro variable so quotes are not needed to tell the difference between strings and names. Everything is string to the macro processor.&lt;/P&gt;
&lt;PRE&gt;1236  %let x1=%sysfunc(intnx(month,%sysfunc(today()),-3,s),date9.);
1237  %put &amp;amp;x1;
15JAN2019
&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Apr 2019 21:33:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/551259#M153154</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-04-15T21:33:37Z</dc:date>
    </item>
  </channel>
</rss>

