11-07-2016 05:49 PM
I am trying to create percentiles through Proc Univariate and I am using the below code
proc univariate data=abdef;
output out = data5 pctlpre=Total_AMT_P_ pctlpts= 0.9 to 99.9 by 10 ;
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.
11-07-2016 06:13 PM
You have to first calculate the decile to group your data before you can calculate the remaining statistics.
11-07-2016 09:49 PM
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
11-07-2016 10:00 PM
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.
11-07-2016 10:21 PM
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.
11-07-2016 10:26 PM - edited 11-07-2016 10:26 PM
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....
11-07-2016 10:30 PM
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.
11-07-2016 10:56 PM
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.
11-10-2016 10:55 AM
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;