I am running some basic descriptive statistics using PROC MEANS (Means, Medians, IQR, etc.). However, the median and IQR values are being automatically rounded to the integer value. Is there a way that I can have it report to a particular decimal place (such as the tenth, in 0.25 increments; rather than '4' could be '3.75' for example)?
Thank you. (using SAS version 9.4 windowing environment)
PROC MEANS DATA = clean2 N MEAN STDDEV MEDIAN P25 P75 MIN MAX maxdec=2;
class age;
var hosp_dur_1 ;
format age agecat.;
RUN;
Output:
4820 | 4.90 | 7.94 | 3.00 | 3.00 | 5.00 | 1.00 | 328.00 |
4080 | 4.58 | 5.13 | 3.00 | 3.00 | 5.00 | 1.00 | 122.00 |
11996 | 7.71 | 320.16 | 4.00 | 3.00 | 5.00 | -1.00 | 35066.00 |
In the proc means you cannot specify a round-off unit.
You would have to output the stats to a table then use the round function in
the Data Step.
In you proc means add:
OUTPUT OUT=MYTABLE MEDIAN=MEDIAN P25=P25 P75=P75;
Data Step would look something like this:
data new;
set MYTABLE;
median=round(median,.25);
p25=round(p25,.25);
P75=round(P75,.25);
format median p25 P75 10.4;
run;
What makes you think rounding is occurring and the 0's are not valid?
If you have a value that's measured in integers I would expect to see either 0, or 0.5 as the decimal portions unless you have a lot of ties.
FYI - you're reporting percentiles (components of IQR) but not IQR as far as I can see in that code.
@lsandell wrote:
I am running some basic descriptive statistics using PROC MEANS (Means, Medians, IQR, etc.). However, the median and IQR values are being automatically rounded to the integer value. Is there a way that I can have it report to a particular decimal place (such as the tenth, in 0.25 increments; rather than '4' could be '3.75' for example)?
Thank you. (using SAS version 9.4 windowing environment)
PROC MEANS DATA = clean2 N MEAN STDDEV MEDIAN P25 P75 MIN MAX maxdec=2; class age; var hosp_dur_1 ; format age agecat.; RUN;
Output:
N Mean Std Dev Median 25th Pctl 75th Pctl Minimum Maximum
4820 4.90 7.94 3.00 3.00 5.00 1.00 328.00 4080 4.58 5.13 3.00 3.00 5.00 1.00 122.00 11996 7.71 320.16 4.00 3.00 5.00 -1.00 35066.00
In the proc means you cannot specify a round-off unit.
You would have to output the stats to a table then use the round function in
the Data Step.
In you proc means add:
OUTPUT OUT=MYTABLE MEDIAN=MEDIAN P25=P25 P75=P75;
Data Step would look something like this:
data new;
set MYTABLE;
median=round(median,.25);
p25=round(p25,.25);
P75=round(P75,.25);
format median p25 P75 10.4;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.