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,
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;
Here is one way of doing that :
data want2;
set want;
format median_pulse pctile_95 10.1;
run;
You can put the format statement in PROC MEANS.
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;
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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.