BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
KLR65
Calcite | Level 5

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! Smiley Happy

%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.

1 ACCEPTED SOLUTION

Accepted Solutions
KLR65
Calcite | Level 5

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...

View solution in original post

3 REPLIES 3
KLR65
Calcite | Level 5

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...

Tom
Super User Tom
Super User

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;

KLR65
Calcite | Level 5

Thank you Tom! I will try that too! Smiley Happy

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1362 views
  • 3 likes
  • 2 in conversation