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-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 6 replies
  • 1413 views
  • 4 likes
  • 5 in conversation