I wanted to write the program in one pass where the data is read once for all variable and observations and not many times to complete the job belowDtaonce for :
%do i=1 %to &no_var;
proc sql;
create table var&i as
select &&name&i from a;
quit;
%end;
%do i=1 %to &no_var;
proc sql noprint;
create table miss&i as
select count(*)/&no_obs as mlsing
from var&i
where &&name&i=.;
quit;
%end;
%do i=1 %to &no_var;
proc sql noprint;
create table zero&i as
select count(*)/&no_obs as zlrou
from var&i
where &&name&i=0;
quit;
%end;
What is it you want to accomplish? If it is just getting counts of missing and non-missing values, take a look at:
SAS FAQ: How can I see the number of missing values and patterns of missing valuesin my data file?
Also, you can get a list or file of all variable names using dictionary.columns
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.