Thank you! This solved my problem without the need to create numerous macrovariables. *reference set to run test sets against;
data refset;
length id $7.;
do i=1 to 30000;
id=strip(put(i,$7.));
output;
end;
run;
*test sets to test code against;
data testset1 testset2 testset3;
length id $7.;
do i=1 to 1000;
id=strip(put(round(ranuni(0)*1000),$7.));
if i < 300 then output testset1;
else if 300 < i < 600 then output testset2;
else output testset3;
output;
end;
run;
*list macro;
%macro test;
%let dsid=%sysfunc(open(refset));
%let cnt=%sysfunc(attrn(&dsid,nobs));
%do i=1 %to &cnt;
%let rc=%sysfunc(fetchobs(&dsid,&i));
"%cmpres(%sysfunc(getvarc(&dsid,%sysfunc(varnum(&dsid,id)))))"
%end;
%let rc=%sysfunc(close(&dsid));
%mend test;
%let start=1;
%let stop=3;
*run files based on key variable list;
Data resultset;
set %macro idloop;
%do x=&start %to &stop %by 1;
testset&x (keep=id)
%end;
%mend idloop;
%idloop;;
where id in (%test);
run;
... View more