Hello everybody,
I have a dataset of this kind:
data have;
input var;
datalines;
34
54
.a
.b
65
.b
; As you can see I have different kinds of missing values identified with "A" and "B".
I would like to know how many A and B missing values are there:
e.g. A: 1; B: 2
Does anybody know how?
Thank you very much!
SAS Version: 9.4
You can use Proc Summary with the Missing Option like this. The _FREQ_ Variables gives you the answer.
data have;
input var;
datalines;
34
54
.a
.b
65
.b
;
proc summary data = have missing nway;
class var;
output out=want;
run;
Result:
Obs var _TYPE_ _FREQ_ 1 A 1 1 2 B 1 2 3 34 1 1 4 54 1 1 5 65 1 1
You can use Proc Summary with the Missing Option like this. The _FREQ_ Variables gives you the answer.
data have;
input var;
datalines;
34
54
.a
.b
65
.b
;
proc summary data = have missing nway;
class var;
output out=want;
run;
Result:
Obs var _TYPE_ _FREQ_ 1 A 1 1 2 B 1 2 3 34 1 1 4 54 1 1 5 65 1 1
Hello @riccardo88,
Or use PROC FREQ:
proc freq data=have;
tables var / missing;
run;
You can restrict the counts to missing values by adding a WHERE statement to this step, e.g.
where missing(var);
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.