I think this example is what you are looking for First I have 2 simple programs that I'm going to %include (program1.sas & program2.sas):
data _null_ ;
put "This is program 1 with CUSTID=&custId" ;
run ;
data _null_ ;
put "This is program 2 with CUSTID=&custId" ;
run ;
Then I have this
filename inc1 "<path>\program1.sas" ;
filename inc2 "<path>\program2.sas" ;
data customerIds ;
infile cards ;
input custId $ ;
call symput("custId"!!left(putn(_n_,"2.")),custId) ;
call symput("count",putn(_n_,"2.")) ;
cards ;
Cust#001
Cust#002
;
%macro repeat ;
%do i=1 %to &count ;
%let custId=&&custId&i ;
%include inc1 ;
%include inc2 ;
%end ;
%mend repeat ;
%let custId=Customer#001 ;
data _null_ ;
%repeat ;
run ;
Here's the log:
272 %let custId=Customer 001 ;
273
274 filename inc1 "<Path>\program1.sas" ;
275 filename inc2 "<Path>\program2.sas" ;
276
277 data customerIds ;
278 infile cards ;
279 input custId $ ;
280 call symput("custId"!!left(putn(_n_,"2.")),custId) ;
281 call symput("count",putn(_n_,"2.")) ;
282 cards ;
NOTE: The data set WORK.CUSTOMERIDS has 2 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
285 ;
286
287 %macro repeat ;
288 %do i=1 %to &count ;
289 %let custId=&&custId&i ;
290 %include inc1 ;
291 %include inc2 ;
292 %end ;
293 %mend repeat ;
294
295 %let custId=Customer#001 ;
296
297 data _null_ ;
298 %repeat ;
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
This is program 1 with CUSTID=Cust#001
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
This is program 2 with CUSTID=Cust#001
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
This is program 1 with CUSTID=Cust#002
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
This is program 2 with CUSTID=Cust#002
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
317 run ;
... View more