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);
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.