DATA Step, Macro, Functions and more

macrovar would not resolve; parallel wont run

Reply
New Contributor
Posts: 3

macrovar would not resolve; parallel wont run



options sascmd="C:\Program Files\SAS 9.4\x86\SASFoundation\9.4\sas.exe"
autosignon;


%macro parallel(n);/*n = # of parallel processes*/


%let p=1;
%let id1=&n+1;
%do%while (&p< &id1);

rsubmit para&p wait=no sysrputsync=yes;
options remote=cpsc01 comamid=tcp;
/* ---------------------------------------------------------------- */
filename rlink "C:\Users\dylan.liu\Documents\psc01.txt";
signon cpsc01;
%syslput p=&p;

%macro testttt (jobnum);
%syslput jobnum=&jobnum;

rsubmit; /*Tells SAS to submit to UNIX, as opposed to PC */
libname ndw oracle user=B1xxx7361_OTSUKA_CUSTOM password=B1xxx7361 path=paa schema=B1xxx7361_OTSUKA_CUSTOM;
endrsubmit;
rsubmit;
options obs=MAX;

data _null_;
%let _EFIERR_ = 0; /* set the ERROR detection macro variable */
%let _EFIREC_ = 0; /* clear export record count macro variable */
file "/fs501.1/SAS/FINAL_RPT_1803_TEST&jobnum..csv" delimiter=',' DSD DROPOVER lrecl=32767;
if _n_ = 1 then /* write column names or labels */
do;
put
"IMSID"
;
end;
set NDW.FINAL_RPT_1803_unknown end=EFIEOD;
format IMS_RXER_ID $7.;
do;
EFIOUT + 1;
PUT IMS_RXER_ID $ @;
;
end;
if _ERROR_ then call symputx('_EFIERR_',1); /* set ERROR detection macro variable */
if EFIEOD then call symputx('_EFIREC_',EFIOUT);
run;
%mend testttt;

%testttt(&p);

endrsubmit;

%let p=%eval(&p+1);
%end;

%mend parallel;

%parallel(4);
run;

 

 

macrovar &p would not resolve; parallel wont run. Please advise.

Super User
Posts: 24,010

Re: macrovar would not resolve; parallel wont run

Posted in reply to laeotropic

This doesn't do what you think it's doing, you need to use %EVAL() here to get the value you need, you can test it with the following:

 

%let n=5;
%let id1=&n+1;
%put &id1.;

So your code should likely be:

 

%let id1=%eval(&n+1);

@laeotropic wrote:



options sascmd="C:\Program Files\SAS 9.4\x86\SASFoundation\9.4\sas.exe"
autosignon;


%macro parallel(n);/*n = # of parallel processes*/


%let p=1;
%let id1=&n+1;
%do%while (&p< &id1);

rsubmit para&p wait=no sysrputsync=yes;
options remote=cpsc01 comamid=tcp;
/* ---------------------------------------------------------------- */
filename rlink "C:\Users\dylan.liu\Documents\psc01.txt";
signon cpsc01;
%syslput p=&p;

%macro testttt (jobnum);
%syslput jobnum=&jobnum;

rsubmit; /*Tells SAS to submit to UNIX, as opposed to PC */
libname ndw oracle user=B1xxx7361_OTSUKA_CUSTOM password=B1xxx7361 path=paa schema=B1xxx7361_OTSUKA_CUSTOM;
endrsubmit;
rsubmit;
options obs=MAX;

data _null_;
%let _EFIERR_ = 0; /* set the ERROR detection macro variable */
%let _EFIREC_ = 0; /* clear export record count macro variable */
file "/fs501.1/SAS/FINAL_RPT_1803_TEST&jobnum..csv" delimiter=',' DSD DROPOVER lrecl=32767;
if _n_ = 1 then /* write column names or labels */
do;
put
"IMSID"
;
end;
set NDW.FINAL_RPT_1803_unknown end=EFIEOD;
format IMS_RXER_ID $7.;
do;
EFIOUT + 1;
PUT IMS_RXER_ID $ @;
;
end;
if _ERROR_ then call symputx('_EFIERR_',1); /* set ERROR detection macro variable */
if EFIEOD then call symputx('_EFIREC_',EFIOUT);
run;
%mend testttt;

%testttt(&p);

endrsubmit;

%let p=%eval(&p+1);
%end;

%mend parallel;

%parallel(4);
run;

 

 

macrovar &p would not resolve; parallel wont run. Please advise.


 

Super User
Posts: 4,025

Re: macrovar would not resolve; parallel wont run

Posted in reply to laeotropic

Your whole approach is likely to be problematic. Doing remote SUBMITs to multiple SAS sessions inside a macro means that you are spreading your macro logic across all those sessions and hoping it all synchronises OK, even though all of those "child" sessions are not aware they are embedded in a macro that is defined only in the primary SAS session.

 

A better approach would be to use the DATA step CALL EXECUTE to generate your required statements in open SAS code, rather than contained inside a SAS macro. 

Ask a Question
Discussion stats
  • 2 replies
  • 95 views
  • 2 likes
  • 3 in conversation