Try this: data work.loop; infile datalines; input col1 $; datalines; x y z ; run; data work.data; infile datalines; input col1 $ col2; datalines; x 1 y 2 z 3 ; run; %macro loop(txt); proc print data=work.data (where=(col1="&txt.")); run; %mend; %macro readds; %let dsid = %sysfunc(open(work.loop,in)); %let nobs = %sysfunc(attrn(&dsid,nlobs)); %put nobs=&nobs; %do i = 1 %to &nobs; %let rc = %sysfunc(fetch(&dsid,'NOSET')); %let col1 = %sysfunc(getvarc(&dsid,%sysfunc(varnum(&dsid,col1)))); %put col1=&col1; %loop(&col1) %end; %let rc = %sysfunc(close(&dsid)); %mend; %readds
... View more