Hi Ron, Thanks for suggestion. I tested your method, but didn't work on my case. Finally, I did them step by step, and get my result. data loop; merge test1 (in=A) test2 (in=B); by pgname; index="&inexpmg"; if index="1" then do; if A; end; if index="2" then do; if A & B; end; if index="3" then do; if A & ^B; end; run; proc sql noprint; select pgname into :pgnameok separated by " " from loop; quit; %macro loop; %let i=1; %let ds = %scan(&pgnameok.,&i.); %do %while ( &ds ^= () ); %inc "C:\Program Files\......\..........\..................\...\\&ds..sas"; %let i=%eval(&i+1); %let ds = %scan(&pgnameok.,&i.); %end; %mend; Thanks for everyone's join for creating different ideas 😄
... View more