# Calculating Percentiles with SAS

In SAS, you can calculate percentiles using PROC UNIVARIATE procedure.

Important options used for calculating percentile in PROC UNIVARIATE
1. PCTLPTS : Specifies percentile levels
2. PCTLPRE : Specifies one or more prefixes to create the variable names for the variables that contain the PCTLPTS= percentiles.
3. PCTLNAME : Specifies one or more suffixes to create the variable names for the variables that contain the PCTLPTS= percentiles.
Example 1 :

Percentile calculation for a variable
proc univariate data = abcd noprint;
var a;
output out=outdata PCTLPTS = 99.5 PCTLPRE = a;
run;
Example 2 :

Percentile calculation for multiple variables
proc univariate data = abcd noprint;
var a b c;
output out=outdata PCTLPTS = 99 PCTLPRE = a b c PCTLNAME = _P99;
run;

2 Important Points :

1. If you specify 3 variables in var statement (var a b c) and only 1 prefix in PCTPRE, SAS will create percentile for only 1 variable that is mentioned first in the var statement.
2. If the number of PCTLNAME= values is fewer than the number of percentiles or if you omit PCTLNAME=, PROC UNIVARIATE uses the percentile as the suffix to create the name of the variable that contains the percentile.

Example 3 :

Series of percentile levels
proc univariate data = abcd noprint;
var c;
output out=outdata PCTLPTS = 0 to 5 by 0.5 , 95 to 100 by 0.5 PCTLPRE = P;
run; Related Posts Deepanshu founded ListenData with a simple objective - Make analytics easy to understand and follow. He has over 10 years of experience in data science. During his tenure, he has worked with global clients in various domains like Banking, Insurance, Private Equity, Telecom and Human Resource.

1 Response to "Calculating Percentiles with SAS"
1. Hi ,I am an avid follower of your posts and it has helped a lot in clearing and understanding certain concepts for first of all a BIG BIG THANKS for posting these articles.
For percentiles I would like to share one article which I came across which shares the secret of getting percentile of multiple variable at one go, and also some custom percentiles. Have a look and let me know your thoughts on the same..

http://blogs.sas.com/content/iml/2013/10/23/percentiles-in-a-tabular-format.html

Next → ← Prev
Love this Post? Spread the Word!
Share