Well, firstly, why is your AE data changing each time? Standard CRF -> Standard Dataset -> Standard SDTM dataset etc.
Secondly, if you know those variables are fixed, and may or may not exist then do:
data loop;
set sashelp.vcolumn (where=(libname="WORK" and memname="AE"
and name in ("AEBODSYS","AESCOC","AESOCCD"...));
call execute('proc sql; create table AE_DISTINCT_'||strip(name)||' as select distinct AEDECOD,'||strip(name)||' from WORK.AE; quit;');
run;
Thus, the code will, for each existing variable in the given list, generate the proc sql code to generate the dataset. Saves typing all that each time. Although saying that, why not just use one of the procedures, proc freq for instance, and just get each combination of distinct variables, something like (and not at work so can't check):
proc freq data=work.ae out=tmp;
run;
That should give you all the distinct value / pairs and you can take your lists from one dataset then.
... View more