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);
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.