I was trying to answer your question about the difference between IF and WHERE. But, there are some good points that have been brought up. Here is a semi-generic macro that checks the flag variable to determine if it is numeric or character and allows you to use a where statement, which is more efficient for large datasets since it is done as the data is brought in and not after, and avoids the automatic conversions done by SAS. %macro chkit(indata=test,outdata=result,flag=flag); %let dsid=%sysfunc(open(&indata)); %let vartype = %sysfunc(vartype(&dsid,%sysfunc(varnum(&dsid,&flag)))); %let rc=%sysfunc(close(&dsid)); data &outdata; set &indata; %if &vartype = N %then %do; where &flag in (0,1); %end; %else %do; where &flag in ('0','1'); %end; run; %mend chkit; Good luck!
... View more