SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
lsandell
Obsidian | Level 7

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
48204.907.943.003.005.001.00328.00
40804.585.133.003.005.001.00122.00
119967.71320.164.003.005.00-1.0035066.00

 

1 ACCEPTED SOLUTION

Accepted Solutions
JOL
SAS Employee JOL
SAS Employee
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;

View solution in original post

3 REPLIES 3
Reeza
Super User

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

 


 

Reeza
Super User
And I'd definitely double check records with negative durations.
JOL
SAS Employee JOL
SAS Employee
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-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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
  • 3 replies
  • 8442 views
  • 1 like
  • 3 in conversation