You may to create a macro and pass variable to it to find duplicates. I have created a macro to do the same on your dummy table & it's working. data test; input id x1 x2 x3 x4; datalines; 1 0 1 3 4 1 1 1 2 3 2 2 4 6 8 2 2 6 5 5 3 3 3 7 3 3 3 3 3 7 ; run; proc contents data = test(drop=id) noprint out = data_info (keep = name varnum); run; proc sql; select name into: name1- from data_info; quit; %put &name1 &name2 &name3 &name4; %macro find_dup_var(tab=,key=,var=); proc sql noprint; create table tab&var. as select count(distinct &var.) as &var._cnt from &tab group by &key; quit; proc sql; select "&var." as duplicate_variable from tab&var. having min(&var._cnt) =1; quit; %mend find_dup_var; %macro run1(); %do i=1 %to 4; %find_dup_var(tab=test,key=id,var=&&name&i.) %end; %mend; %run1;
... View more