Can anyone explain why SAS on Unix (remote submit) does not create my macro variables correctly? This code works on PC SAS side but seems to choke (with no error) on the UNIX SAS side of things.. Thanks!
%MACRO EDW2;
RSUBMIT;
data _null_;
format dtstr1 dtstr2 dtstr3 DATE9.;
dtstr1 = INTNX('MONTH',(INTNX('MONTH',date(),-1)),+0,'BEGINNING');
dtstr2 = INTNX('MONTH',(INTNX('MONTH',date(),-1)),+0,'END');
dtstr3 = INTNX('MONTH',(INTNX('MONTH',date(),-1)),-1,'END');
call SYMPUT('RPTMTH',put(dtstr1,YYMMN.));
call SYMPUT('BEGPRIOR',put(dtstr1,DATE9.));
call SYMPUT('DATADT',put(dtstr2,DATE9.));
call SYMPUT('ODATE',"'"||put(dtstr2,date7.)||"'");
call SYMPUT('PDATE',"'"||put(dtstr3,date7.)||"'");
run;
%put RPTMTH = "&RPTMTH." BEGPRIOR = "&BEGPRIOR." DATADT = "&DATADT." ODATE = "&ODATE." PDATE = "&PDATE.";
ENDRSUBMIT;
%MEND EDW2;
%EDW2;
Log Results:
1776 %MACRO EDW2;
1777
1778 RSUBMIT;
1779
1781 data _null_;
1782 format dtstr1 dtstr2 dtstr3 DATE9.;
1783 dtstr1 = INTNX('MONTH',(INTNX('MONTH',date(),-1)),+0,'BEGINNING');
1784 dtstr2 = INTNX('MONTH',(INTNX('MONTH',date(),-1)),+0,'END');
1785 dtstr3 = INTNX('MONTH',(INTNX('MONTH',date(),-1)),-1,'END');
1786 call SYMPUT('RPTMTH',put(dtstr1,YYMMN.));
1787 call SYMPUT('BEGPRIOR',put(dtstr1,DATE9.));
1788 call SYMPUT('DATADT',put(dtstr2,DATE9.));
1789 call SYMPUT('ODATE',"'"||put(dtstr2,date7.)||"'");
1790 call SYMPUT('PDATE',"'"||put(dtstr3,date7.)||"'");
1791 run;
1792
1793 %put RPTMTH = "&RPTMTH." BEGPRIOR = "&BEGPRIOR." DATADT = "&DATADT." ODATE = "&ODATE." PDATE
1793! = "&PDATE.";
1794
1795 ENDRSUBMIT;
1796
1797 %MEND EDW2;
1798 %EDW2;
MLOGIC(EDW2): Beginning execution.
MPRINT(EDW2): RSUBMIT
NOTE: Remote submit to REMOTEID commencing.
MPRINT(EDW2): ; data _null_;
MPRINT(EDW2): format dtstr1 dtstr2 dtstr3 DATE9.;
MPRINT(EDW2): dtstr1 = INTNX('MONTH',(INTNX('MONTH',date(),-1)),+0,'BEGINNING');
MPRINT(EDW2): dtstr2 = INTNX('MONTH',(INTNX('MONTH',date(),-1)),+0,'END');
MPRINT(EDW2): dtstr3 = INTNX('MONTH',(INTNX('MONTH',date(),-1)),-1,'END');
MPRINT(EDW2): call SYMPUT('RPTMTH',put(dtstr1,YYMMN.));
MPRINT(EDW2): call SYMPUT('BEGPRIOR',put(dtstr1,DATE9.));
MPRINT(EDW2): call SYMPUT('DATADT',put(dtstr2,DATE9.));
MPRINT(EDW2): call SYMPUT('ODATE',"'"||put(dtstr2,date7.)||"'");
MPRINT(EDW2): call SYMPUT('PDATE',"'"||put(dtstr3,date7.)||"'");
MPRINT(EDW2): run;
MLOGIC(EDW2): %PUT RPTMTH = "&RPTMTH." BEGPRIOR = "&BEGPRIOR." DATADT = "&DATADT." ODATE =
"&ODATE." PDATE = "&PDATE."
WARNING: Apparent symbolic reference RPTMTH not resolved.
WARNING: Apparent symbolic reference BEGPRIOR not resolved.
WARNING: Apparent symbolic reference DATADT not resolved.
WARNING: Apparent symbolic reference ODATE not resolved.
WARNING: Apparent symbolic reference PDATE not resolved.
RPTMTH = "&RPTMTH." BEGPRIOR = "&BEGPRIOR." DATADT = "&DATADT." ODATE = "&ODATE." PDATE =
"&PDATE."
MPRINT(EDW2): ENDRSUBMIT;
749 data _null_;
750 format dtstr1 dtstr2 dtstr3 DATE9.;
751 dtstr1 = INTNX('MONTH',(INTNX('MONTH',date(),-1)),+0,'BEGINNING');
752 dtstr2 = INTNX('MONTH',(INTNX('MONTH',date(),-1)),+0,'END');
753 dtstr3 = INTNX('MONTH',(INTNX('MONTH',date(),-1)),-1,'END');
754 call SYMPUT('RPTMTH',put(dtstr1,YYMMN.));
755 call SYMPUT('BEGPRIOR',put(dtstr1,DATE9.));
756 call SYMPUT('DATADT',put(dtstr2,DATE9.));
757 call SYMPUT('ODATE',"'"||put(dtstr2,date7.)||"'");
758 call SYMPUT('PDATE',"'"||put(dtstr3,date7.)||"'");
759 run;
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
NOTE: Remote submit to REMOTEID complete.
MLOGIC(EDW2): Ending execution.
The problem is resolved when I move the %macro start and end to within the RSUBMIT and ENDRSUBMIT statement. The macro being active only on the local side made it work incorrectly...
The problem is resolved when I move the %macro start and end to within the RSUBMIT and ENDRSUBMIT statement. The macro being active only on the local side made it work incorrectly...
Another way is to prevent the local session from evaluating the macro statements by using %NRSTR().
%macro xx;
rsubmit;
data _null_;
call symputx('newvar','remote');
run;
%nrstr(%put &newvar) ;
endrsubmit;
%mend xx;
%xx;
Thank you Tom! I will try that too!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.