Calculating Percentiles with SAS

Live Online Training : SAS Programming with 50+ Case Studies

- Explain Programming Concepts in Simple English
- Live Projects
- Scenario Based Questions
- Job Placement Assistance
- Get 10% off till Oct 26, 2017
- Batch starts from October 28, 2017

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;

SAS Tutorials : 100 Free SAS Tutorials

About Author:

Deepanshu founded ListenData with a simple objective - Make analytics easy to understand and follow. He has close to 7 years of experience in data science and predictive modeling. During his tenure, he has worked with global clients in various domains like retail and commercial banking, Telecom, HR and Automotive.


While I love having friends who agree, I only learn from those who don't.

Let's Get Connected: Email | LinkedIn

Get Free Email Updates :
*Please confirm your email address by clicking on the link sent to your Email*

Related Posts:

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

    ReplyDelete

Next → ← Prev