BookmarkSubscribeRSS Feed
laeotropic
Calcite | Level 5



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.

2 REPLIES 2
Reeza
Super User

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.


 

SASKiwi
PROC Star

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. 

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
  • 2 replies
  • 565 views
  • 2 likes
  • 3 in conversation