Hi, I made this code some time ago. The macro takes a library in library=parameter and all the datasets inside. Checks for columns with all variables missing and does a copy of the table which is written to library in outlib=parameter. It also adds 'nomiss' string at the end of each table name. As the macro generates a lot of code, it is written to temporary external file %macro new(library=,outlib=); %local i j k; proc sql noprint; select memname into :tables separated by " " from dictionary.tables where libname="%upcase(&library.)"; quit; %do i = 1 %to %util_countwords(&tables.); proc sql noprint; create table my_dictionary_columns as select name, monotonic() as N from dictionary.columns where memname="%scan(&tables,&i.)" and libname="%upcase(&library.)"; quit; data _null_; file 'temp.txt'; set my_dictionary_columns end=the_end; put "retain miss" _N_" 0; miss" _N_"=missing"; put "(" name ")"; put "+miss" _N_";keep miss" _N_";"; if the_end then call symputx('N_columns',_N_); run; /* option symbolgen;*/ data miss%scan(&tables,&i.); set %upcase(&library.).%scan(&tables,&i.) end=the_end; %include 'temp.txt'; nasumeno+1; keep nasumeno; if the_end then output; run; data concated; set miss%scan(&tables,&i.); array misses miss: ; keep i ; do i = 1 to dim(misses); if misses/nasumeno=1 then do; check+1; output; end; end; call symputx('check',check); run; proc sql noprint; create table to_delete as select a.name from my_dictionary_columns as a inner join concated as b on(a.N=b.i) ; quit; data _null_; file 'drop_temp.txt'; set to_delete; put "drop " name ";"; run; /****************************************************************************************************/ data &outlib..%substr(%scan(&tables,&i.),1,%sysfunc(min(27,%length(%scan(&tables,&i.)))))nomis; set %upcase(&library.).%scan(&tables,&i.); ; %if &check.>0 %then %do; %include 'drop_temp.txt'; %put &check. variables removed due to missing values from %upcase(&library.).%scan(&tables,&i.); %end; %else %do; %put no missing data discovered in table %upcase(&library.).%scan(&tables,&i.); %end; run; %end; %mend new; %new(outlib=&outlib.,library=&library.); Jakub
... View more