<?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: Resolving macro variable creating data-step read error in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Resolving-macro-variable-creating-data-step-read-error/m-p/810657#M319686</link>
    <description>&lt;P&gt;You did not set a length for the variable yymmp, so it "inherits" the length from lrpt_yymmdd,, and has trailing blanks. Using CALL SYMPUTX instead of CALL SYMPUT works around this (SYMPUTX strips leading and trailing blanks, like a %LET).&lt;/P&gt;</description>
    <pubDate>Fri, 29 Apr 2022 14:18:48 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-04-29T14:18:48Z</dc:date>
    <item>
      <title>Resolving macro variable creating data-step read error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-macro-variable-creating-data-step-read-error/m-p/810630#M319676</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data _null_;
call symput('yymmp',PUT(intnx('Month',"&amp;amp;SYSDATE"d,-2,'Ending'),yymmn4.));
run;
%put &amp;amp;=yymmp;

data _time_;
lrpt_dte = intnx('MONTH', "&amp;amp;SYSDATE"d, -2, 'B');
lrpt_yyyymmdd = input(put(lrpt_dte,yymmddn8.),$8.); *20180228;	
yymmp = substr(lrpt_yyyymmdd,3,4);
call symput('yymmp',yymmp);
run;
%put &amp;amp;=yymmp;

data  v_rskp;
set gcbc.eop_&amp;amp;yymmp._drv_rskp; 
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I have two ways off creating the macro variable &amp;amp;YYMMP.&amp;nbsp;&lt;/P&gt;&lt;P&gt;And both according to logs return 2202&lt;/P&gt;&lt;P&gt;May I know why the data-step return error when I use the 2nd way of assigning &amp;amp;YYMMP.&lt;/P&gt;&lt;P&gt;Why isn't it resolving to&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;gcbc.eop_2202_drv_rskp&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LOGS:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;21         
22         data _null_;
23         call symput('yymmp',PUT(intnx('Month',"&amp;amp;SYSDATE"d,-2,'Ending'),yymmn4.));
24         run;

NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

25         %put &amp;amp;=yymmp;
YYMMP=2202
26         
27         data _time_;
28         lrpt_dte = intnx('MONTH', "&amp;amp;SYSDATE"d, -2, 'B');
29         lrpt_yyyymmdd = input(put(lrpt_dte,yymmddn8.),$8.); *20180228;	
30         yymmp = substr(lrpt_yyyymmdd,3,4);
31         call symput('yymmp',yymmp);
32         run;

NOTE: Compression was disabled for data set WORK._TIME_ because compression overhead would increase the size of the data set.
NOTE: The data set WORK._TIME_ has 1 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

33         %put &amp;amp;=yymmp;
YYMMP=2202
34         
35         data  v_rskp;
36         set gcbc.eop_&amp;amp;yymmp._drv_rskp;
ERROR: File GCBC.EOP_2202.DATA does not exist.
37         run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is able to resolve to correct dataset name when I use the first way of assigning the macro variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 13:36:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-macro-variable-creating-data-step-read-error/m-p/810630#M319676</guid>
      <dc:creator>hellind</dc:creator>
      <dc:date>2022-04-29T13:36:08Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving macro variable creating data-step read error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-macro-variable-creating-data-step-read-error/m-p/810644#M319679</link>
      <description>&lt;P&gt;Add TRIM&amp;nbsp; to your call symput:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symput('yymmp'trim(,yymmp));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I ran a simple test, and got a slightly different error to you, but it gave me enough of a hint in the ERROR: messages&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;94  data _time_;
395  lrpt_dte = intnx('MONTH', "&amp;amp;SYSDATE"d, -2, 'B');
SYMBOLGEN:  Macro variable SYSDATE resolves to 29APR22
396  lrpt_yyyymmdd = input(put(lrpt_dte,yymmddn8.),$8.); *20180228;
397  yymmp = substr(lrpt_yyyymmdd,3,4);
398  call symput('yymmp',yymmp);
399  ll=length(yymmp) ;
400  put _all_ ;
401
402  run;

lrpt_dte=22677 lrpt_yyyymmdd=20220201 yymmp=2202 ll=4 _ERROR_=0 _N_=1
NOTE: The data set WORK._TIME_ has 1 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


403
404  options symbolgen ;
405
406  data test ;
SYMBOLGEN:  Macro variable YYMMP resolves to 2202
407      set eop_&amp;amp;yymmp._drv_rskp ;
&lt;FONT color="#FF0000"&gt;ERROR: File WORK.EOP_2202.DATA does not exist.
ERROR: File WORK._DRV_RSKP.DATA does not exist.&lt;/FONT&gt;
408  run ;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 13:57:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-macro-variable-creating-data-step-read-error/m-p/810644#M319679</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2022-04-29T13:57:11Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving macro variable creating data-step read error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-macro-variable-creating-data-step-read-error/m-p/810653#M319685</link>
      <description>&lt;P&gt;For most purposes just use the normal (no longer NEW by any definition of that word) &lt;STRONG&gt;CALL SYMPUTX()&lt;/STRONG&gt; function instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symputX('yymmp',yymmp);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;You should really only use the OLD (very very old) CALL SYMPUT() function if you have some special need to store leading and/or trailing spaces into the macro variable.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another possible issue to watch out for is parsing issues.&amp;nbsp; Sometimes in macro code building a single SAS token from macro code confuses the SAS parser and it sees the value as two token, even though there isn't really any space there.&amp;nbsp; You can use %UNQUOTE() to fix that.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set %unquote(gcbc.eop_&amp;amp;yymmp._drv_rskp);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or what I find easier to understand is to just build the value into another macro variable and use that.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dsname=gcbc.eop_&amp;amp;yymmp._drv_rskp;
set &amp;amp;dsname.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But you should not see that in the open code example you posted.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 14:12:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-macro-variable-creating-data-step-read-error/m-p/810653#M319685</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-04-29T14:12:26Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving macro variable creating data-step read error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-macro-variable-creating-data-step-read-error/m-p/810657#M319686</link>
      <description>&lt;P&gt;You did not set a length for the variable yymmp, so it "inherits" the length from lrpt_yymmdd,, and has trailing blanks. Using CALL SYMPUTX instead of CALL SYMPUT works around this (SYMPUTX strips leading and trailing blanks, like a %LET).&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 14:18:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-macro-variable-creating-data-step-read-error/m-p/810657#M319686</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-04-29T14:18:48Z</dc:date>
    </item>
  </channel>
</rss>

