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
You have to first calculate the decile to group your data before you can calculate the remaining statistics.
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
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.
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.
Obs | Process | Total_Amt_P_0_9 | Total_Amt_P_10_9 | Total_Amt_P_20_9 | Total_Amt_P_30_9 | Total_Amt_P_40_9 | Total_Amt_P_50_9 | Total_Amt_P_60_9 | Total_Amt_P_70_9 | Total_Amt_P_80_9 | Total_Amt_P_90_9 |
1 | A | 123.46 | 124.46 | 125.46 | 126.46 | 127.46 | 128.46 | 129.46 | 130.46 | 131.46 | 132.46 |
2 | B | 345.95 | 346.95 | 347.95 | 348.95 | 349.95 | 350.95 | 351.95 | 352.95 | 353.95 | 354.95 |
3 | C | 4305.65 | 4306.65 | 4307.65 | 4308.65 | 4309.65 | 4310.65 | 4311.65 | 4312.65 | 4313.65 | 4314.65 |
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....
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!!
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.
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;
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 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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: