BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Satori
Quartz | Level 8

I am doing a proc freq to count the number of missing and not missing per variable:

 

My code:

proc format; value $missfmt ' '='Missing' other='Not Missing'; value missfmt . ='Missing' other='Not Missing';
proc freq data=have; format _NUMERIC_ missfmt.; tables _NUMERIC_ / missing missprint nocum;

 

What I get is a table for each variable (only one variable - sales - is shown below)

The FREQ Procedure

Sales Frequency Percent
------------------------------------
Missing 10153881 47.32
Not Missing 11304829 52.68

 

What I want is to make sure that the observations that are zero are counted as 'missing' or other class but not as 'not missing'. How can I do this?

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

@Satori wrote:

 

What I want is to make sure that the observations that are zero are counted as 'missing' or other class but not as 'not missing'. How can I do this?


Modify your format to include 0 as missing.

 

proc format;
    value missfmt .,0 ='Missing' other='Not Missing';
run;

 

From now on, please include your SAS code in a code box, as I did above, by clicking on the "little running man" icon and then pasting your code into the window that appears.

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

@Satori wrote:

 

What I want is to make sure that the observations that are zero are counted as 'missing' or other class but not as 'not missing'. How can I do this?


Modify your format to include 0 as missing.

 

proc format;
    value missfmt .,0 ='Missing' other='Not Missing';
run;

 

From now on, please include your SAS code in a code box, as I did above, by clicking on the "little running man" icon and then pasting your code into the window that appears.

--
Paige Miller
WeiChen
Obsidian | Level 7

Zero frequency is not missing frequency. Missing frequency menas you do not know how many times a value is observed. Zero frequency means you do know that it was observed zero times.

SAS Innovate 2025: Register Today!

 

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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