BookmarkSubscribeRSS Feed
dapsy
Calcite | Level 5

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;

1 REPLY 1
art297
Opal | Level 21

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 333 views
  • 0 likes
  • 2 in conversation