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

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;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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.

 

View solution in original post

3 REPLIES 3
Astounding
PROC Star

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.

 

GKati
Pyrite | Level 9
Perfect! Thx
PeterClemmensen
Tourmaline | Level 20

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

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 3 replies
  • 972 views
  • 0 likes
  • 3 in conversation