BookmarkSubscribeRSS Feed
BhararaTej
Fluorite | Level 6

Hi, 

 

I am trying to create percentiles through Proc Univariate and I am using the below code

 

proc univariate data=abdef;
var Total_AMT;
class process;
output out = data5 pctlpre=Total_AMT_P_ pctlpts= 0.9 to 99.9 by 10 ;
run;

 

What I am also trying to do is that I want to create some standard descriptive statistics at each decile like min, max, mean, std etc. 

Could you please help as to how that can be created or will I have to use something else. 

 

Thanks,

Tej

8 REPLIES 8
Reeza
Super User

You have to first calculate the decile to group your data before you can calculate the remaining statistics.

 

 

BhararaTej
Fluorite | Level 6

can you elaborate on what you mean by calculating deciles. 

I thought the deciles are getting calculated in my code when i use

 

pctlpre=Total_AMT_P_  pctlpts= 0.9 to 99.9 by 10

 

I have the deciles, just need now the statistics such as min, max, mean, std

Reeza
Super User

Then run a proc means or univariate on your output data using the calculated decile from step 1 as your BY or CLASS variable to obtain the stats of interest. 

 

You need the deciles before you can group the data. 

BhararaTej
Fluorite | Level 6

The code I mentioned above gives me the below table. It doesnt provides descriptive statistics at each decile. 

for ex: min, max, mean, std for each of the 10 deciles below. 

 

If you have a code, kindly share.

 

 

ObsProcessTotal_Amt_P_0_9Total_Amt_P_10_9Total_Amt_P_20_9Total_Amt_P_30_9Total_Amt_P_40_9Total_Amt_P_50_9Total_Amt_P_60_9Total_Amt_P_70_9Total_Amt_P_80_9Total_Amt_P_90_9
1A123.46124.46125.46126.46127.46128.46129.46130.46131.46132.46
2B345.95346.95347.95348.95349.95350.95351.95352.95353.95354.95
3C4305.654306.654307.654308.654309.654310.654311.654312.654313.654314.65
Reeza
Super User

Oh...you first need to categorize each observation as being within a specific decile group so you can then calculate summary stats. Personally I prefer proc RANK for categorizing data. There isn't an option you can specify to get what you want. 

 

You were doing from 0.9 to 99.9 so were you trying to trim outliers? Unevenly isn't common....

 

 

BhararaTej
Fluorite | Level 6

i am flexible on the deciles, I think at this point in time willing to work with the default deciles as well, but hoping to get the descriptive statistics at each decile in a format where the deciles goes horizontally over the top and the statistics goes vertically in the file (min, max, mean, std) for each decile. 

 

I am guessing I will have to write some custom piece of code to write that. Will explore proc rank as well. 

 

Thanks!!

Reeza
Super User

Actually you may not need custom code 

Use proc RANK with 10 groups to get 10 deciles. 

The use proc tabulate to generate your summaries - this generates a report, displayed output not a dataset. If you want a dataset use PROC means or univariate and then proc transpose. So semi custom if you need a dataset with the output. 

Rick_SAS
SAS Super FREQ

Look at this example for how to use PROC RANK and PROC MEANS. It is not clear to me how you want to use the CLASS variable in your example, but this should get you started:

 

proc rank data=sashelp.cars out=cars groups=10 ;
var mpg_city;
ranks Rank;
run;

proc means data=cars;
class Rank Origin;
var mpg_highway weight length;
run;

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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