Hi All,
I would like to calculate the average of costs at each percentile based on contracts. I got as far as calculating the percentile limits, but this gives me a dataset with varilables; P_1, P-2, ... P_100. I need to somehow merge these into my original dataset and then use proc means I guess to calculate the averege cost per percentile.
What's the most efficient way of doing this?
data claims;
input client year cost contract;
datalines;
18 2011 589.92 10.2
19 2010 1629.8 11.5
20 2011 1813.29 2.3
21 2012 412.06 3.2
22 2012 219.82 0.4
23 2010 3669.98 5.9
24 2012 4879.63 6.8
;
run;
proc univariate data=claims noprint;
var contract;
output pctlpre=P_ pctlpts= 1 to 100;
run;
It can be done, but this is the hard way.
Instead, use PROC RANK to create an output data set with percentile assigned. You won't have the cutoffs, but you won't need them either.
It can be done, but this is the hard way.
Instead, use PROC RANK to create an output data set with percentile assigned. You won't have the cutoffs, but you won't need them either.
Use PROC STDIZE to get results in long format and merge accordingly as in the article below 🙂
https://blogs.sas.com/content/iml/2013/10/23/percentiles-in-a-tabular-format.html
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 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: