Tivos Jar
Tivos Jar

Reputation: 27

SAS: How to include Zeros or Missing Values when calculating Median, Minimum and Maximum?

I am trying to calculate median, minimum and maximum for several variables for last 5 years in Base SAS. Some of the variables had no cases of diseases in some years, so 0 cases. When I calculate summary in SAS, I want to include these zeros.

For example: one of my variable, lets say X, had 8, 6, 2, 0, 0 cases in the last 5 years respectively. When I calculate the summary of this variable either using "proc-sql" or "proc-means", SAS is ignoring those 0's and giving me something different than what I am expecting. I would like to get Min=0, Max=8 and Median=2, but SAS is giving me Min=2, Max=8 and Median=6 as it is ignoring the zeros.

Any suggestion or direction would be appreciated?

Upvotes: 0

Views: 4291

Answers (2)

Reeza
Reeza

Reputation: 21264

SAS will include 0, it will not include missing. You possibly have a format on top of your variable that is showing it as 0 when it's actually missing. Try removing the format and see if that's the case, otherwise, this is the default behaviour of SAS.

You can remove formats using:

format var; *note lack of format, which removes the format;

Or if you set option missing to 0 then it shows missing as 0, but the underlying value is still missing and will not be included. You need to actually change the values to 0.

Upvotes: 0

Craig Srsen
Craig Srsen

Reputation: 475

If you truly have missing data you can replace those with zeroes using PROC STDIZE (assuming you have SAS/STAT).

proc stdize data=have out=want replace; run;

Upvotes: 2

Related Questions