Hello, It need a little bit of refinement (not creating the macro variable allvars manually), but may be a solution: data have; infile datalines missover; input Trait $ Var1 :$7. Var2 :$7. Var300 :$7.; datalines; 1 200/200 120/120 100/100 1 150/150 140/140 99/99 1 100/100 180/180 135/135 1 150/150 120/120 100/100 1 100/100 180/180 160/160 1 150/150 119/119 160/160 1 200/200 140/140 135/135 0 150/150 180/180 0 149/149 140/140 160/160 0 100/100 120/120 133/133 0 100/100 140/140 100/100 0 200/200 180/180 135/135 0 150/150 140/140 160/160 0 200/200 180/180 100/100 0 100/100 120/120 135/135 run; %let allvars=Var1 Var2 Var300; %macro h; %let i=1; %do %while (%scan(&allvars,&i) ne); %let var=%scan(&allvars,&i); proc sql; create table int as select &var, count(&var) as no from have group by &var having no eq 1; quit; data have; set have; if _n_=1 then do; declare hash i(dataset:'int'); i.definekey("&var"); i.definedone(); end; rc=i.check(); if rc=0 then call missing(&var); run; %let i=%eval(&i+1); %end; %mend h; %h
... View more