No macro needed here.
See this code from @Watts https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-data...
@adityaa9z wrote:
Hi. I have to use it on a daily basis for different datasets so adding this code doesn't seem a viable solution which I why was hoping for a macro instead.
But the code will work on every data set, regardless of variable names. How can code that works on every data set, regardless of variable names, not be viable?
%macro check_miss(dsn= , out= );
/* firstl, get variable names */
proc transpose data=&dsn(obs=0) out=vname;
var _all_;
run;
/* then check if variable is all missing */
proc sql noprint;
select catx(' ','nmiss(',_name_,') as',_name_) into :vnames separated by ','
from vname;
create table temp as
select &vnames from have;
quit;
proc transpose data=temp out=&out;
var _all_;
run;
%mend;
/*Test Macro*/
data have;
set sashelp.class;
if _n_ in ( 1 4 6) then call missing(name,age);
run;
%check_miss(dsn=have, out=want)
Check out this article, it may be of some use to you.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.