Search code examples
sasmeanzeroprocproc-sql

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?


Solution

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