BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DeepakSwain
Pyrite | Level 9

Hi there,

 

I am trying to get mean, median and P95 using Proc means in a desired format such as mean_pulse as integer and P50 and P95 

with one decimal. Can some body help me to modify my code to get the desired output.

 

data test;
input id  pulse;
cards;
1 2
4 5
7 8
1 3
4 5
7 8
1 2
4 5
7 9
1 2
4 7
7 8
1 5
4 7
7 8
;
run;
 

proc sort data =test; by id; run;

proc means data =test noprint;
var pulse;
by id ;
output out=want (drop= _type_ _freq_) mean=mean_pulse p50=median_pulse p95=pctile_95;
run;

At present, I am getting median and P95 as whole number but I want with a decimal. 

 

Regards,

 

Swain
1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

proc means data =test noprint;
var pulse;
by id ;
output out=want (drop= _type_ _freq_) mean=mean_pulse p50=median_pulse p95=pctile_95;
format _numeric_ 10.1;
run;

View solution in original post

6 REPLIES 6
pink_poodle
Barite | Level 11

Here is one way of doing that :

 

data want2;
    set want;
    format median_pulse pctile_95 10.1;
run;
DeepakSwain
Pyrite | Level 9
Hi pink_poodle,
Is there a way to put desired format with P50 and P95 in proc means statement.
Swain
PaigeMiller
Diamond | Level 26

You can put the format statement in PROC MEANS.

--
Paige Miller
DeepakSwain
Pyrite | Level 9
Hi PaigeMiller,

Great. I am trying to use format statement with proc means. Can you kindly suggest the necessary modification in the above code.
Thanks
Swain
Ksharp
Super User

proc means data =test noprint;
var pulse;
by id ;
output out=want (drop= _type_ _freq_) mean=mean_pulse p50=median_pulse p95=pctile_95;
format _numeric_ 10.1;
run;
ballardw
Super User

For your mean do want the value to actually be an integer or just appear as such? Apply a format such as F5. and the appearance will be rounded to an integer value. Or use a data step and actually round or truncate the value with ROUNT, FLOOR or CEIL functions.

 

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1162 views
  • 4 likes
  • 5 in conversation