Hi
Good morning sas community
How to get numeric & character missing's variable names and respective datasets names in a Library
The following code I wrote before is to check the variable with all the missing value under WORK library 's all tables.
a.k.a It print the variable name which value are all missing.
%let library=work; /*Here is the library I want to search*/ %macro find_missing_var(dsn); proc transpose data=&dsn(obs=0) out=vname; var _all_; run; proc sql noprint; select catx(' ','n(',_name_,') as',_name_) into :vnames separated by ',' from vname; create table temp as select &vnames from &dsn; quit; proc transpose data=temp out=temp1; var _all_; run; data temp2; length table_name _name_ $ 100; table_name="&dsn"; set temp1; if col1=0; run; proc append base=want data=temp2 force; run; %mend; proc delete data=want; run; data _null_; set sashelp.vtable( keep=libname memname where=(libname="%upcase(&library)") ); call execute(cats('%nrstr(%find_missing_var(',libname,'.',memname,'))')); run; title 'COLUMNS WITHOUT DATA'; proc print; run;
A variable name cannot be "missing". A variable is either present or not present, and when it is present, it has a name, period.
Please explain in more detail what you want to do.
PS terse one-liners are rarely suited to get a good answer. By now, you should know this.
The following code I wrote before is to check the variable with all the missing value under WORK library 's all tables.
a.k.a It print the variable name which value are all missing.
%let library=work; /*Here is the library I want to search*/ %macro find_missing_var(dsn); proc transpose data=&dsn(obs=0) out=vname; var _all_; run; proc sql noprint; select catx(' ','n(',_name_,') as',_name_) into :vnames separated by ',' from vname; create table temp as select &vnames from &dsn; quit; proc transpose data=temp out=temp1; var _all_; run; data temp2; length table_name _name_ $ 100; table_name="&dsn"; set temp1; if col1=0; run; proc append base=want data=temp2 force; run; %mend; proc delete data=want; run; data _null_; set sashelp.vtable( keep=libname memname where=(libname="%upcase(&library)") ); call execute(cats('%nrstr(%find_missing_var(',libname,'.',memname,'))')); run; title 'COLUMNS WITHOUT DATA'; proc print; run;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.