I have a dataset ds1. I want to have a list, that shows me how many missing values there is per (numeric) variabel. I know I can get this by simply using a proc means:
data ds1;
input kon $ age ss;
cards;
M 20 1
K 22 2
M 24 2
M . .
K . .
. . .
;
run;
proc means data=ds1 NMISS N;
run;
But is it possibel to get the exact result output (se attachments) I get from the proc means into a actual dataset, so I use that for further analysis? I want to use it to calcute late the response rate for each variabel/question.
Okay How about proc freq nlevels
data ds1;
input kon $ age ss;
cards;
M 20 1
K 22 2
M 24 2
M . .
K . .
. . .
;
run;
ods output nlevels=want;
proc freq data=ds1 nlevels;
tables age ss / noprint;
run;
Are you asking for OUTPUT OUT statement in proc means?
data ds1;
input kon $ age ss;
cards;
M 20 1
K 22 2
M 24 2
M . .
K . .
. . .
;
run;
proc means data=ds1 NMISS N;
output out=want nmiss= n=/autoname;
run;
Well, not exactly. The output out function gives me the type of data, that I need, but I would like to have one row per variabel, that contains the number of missing and non-missing values for each variabel - just like the "plot" you get in the result window (or see the attached file) when you run the proc means statement.
Okay How about proc freq nlevels
data ds1;
input kon $ age ss;
cards;
M 20 1
K 22 2
M 24 2
M . .
K . .
. . .
;
run;
ods output nlevels=want;
proc freq data=ds1 nlevels;
tables age ss / noprint;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.