I have 7 similar data sets, and I want to select cases that exist in two data sets, so I have 21 combinations of 2 of the 7 sets.
so I want to use a macro to speed this up. Below is my code:
%macro both(A,B);
proc sql;
create table &A&B as
select A.ID, A.Gender, A.age
from &A.demographics as A, &B.demographics as B
where A.ID = B.ID;
quit; * then count; proc sql noprint; select count(*) into :OBSCOUNT from &A&B quit; %put Count=&OBSCOUNT.;
%mend both;
%both(data1,data2)
It works. But I still have to type the 21 combinations, like %both(data1,data2), %both(data1,data3), ...
How can I improve it with a do loop?
also, in the last step,
%put Count=&OBSCOUNT.;
can I print out the two data sets names, &A and &B? how?
Thank you
... View more