BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
riccardo88
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

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 

View solution in original post

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

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 
FreelanceReinh
Jade | Level 19

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

 

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 544 views
  • 2 likes
  • 3 in conversation