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;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.