Also note that you might be able to skip the SQL to count the observations and instead use the NOBS= option on the set statement. data want ; set have nobs=nobs ; if _n_ < nobs/2 ; run;
... View more
If there are not too many different codes then you could also expand your condition table so that it contains all the combinations (and no more missings). This would then allow to use a hash lookup.
... View more