Hi All, I found a macro in the forum to calculate the missing data percentage for each variable in the data set. I tried it and it works, but for some reason the last variable in the data set will be get rid of, I wonder how to fix this macro. Is there anybody can help? Thank you! 1) Macro %macro missing_data(library=,dataset=,xoutdataset=); proc sql noprint; select name into :allvars separated by " " from dictionary.columns where libname="%upcase(&library.)" and memname="%upcase(&dataset.)"; quit; proc sql noprint; create table &xoutdataset. as select %let firstspace=%sysfunc(find(&allvars.,%str( ))); %do %while (&firstspace.>0); %let var=%substr(&allvars.,1,&firstspace.); sum(missing(&var.))/count(*) as &var., %let allvars=%substr(&allvars.,&firstspace.); %let firstspace=%sysfunc(find(&allvars.,%str( ))); %end; 'Y' as done_successfully from &library..&dataset.; quit; %mend missing_data; %missing_data(library=sashelp,dataset=class,xoutdataset=outfile); 2) The output variable list after macro used: Name Sex Age Height done_successfully 3) The variable list in the data set: Name Sex Age Height Weight Compare 2) and 3), we can see the weight variable is gone after using the macro. I wonder how this macro be fixed to include every variables in the data set. Thanks, Jade
... View more