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

Important options used for calculating percentile in PROC UNIVARIATE

**PCTLPTS :**Specifies percentile levels**PCTLPRE :**Specifies one or more**prefixes**to create the variable names for the variables that contain the PCTLPTS= percentiles.**PCTLNAME :**Specifies one or more**suffixes**to create the variable names for the variables that contain the PCTLPTS= percentiles.

The following SAS code calculates the 90th and 99.5th percentile of variable 'a' from the dataset 'abcd' and saves the result to a dataset named 'outdata'.

proc univariate data = abcd noprint; var a; output out=outdata PCTLPTS = 90 99.5 PCTLPRE = a; run;

The following SAS code calculates the 99th percentile of variable 'a', 'b' and 'c' from the dataset 'abcd' and saves the result to a dataset named 'outdata'.

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

**Important Points : **

- 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.
- 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.

The following SAS code calculates percentiles from 0 to 5 by 0.5 increments and from 95 to 100 by 0.5 increments for variable 'c' from the dataset 'abcd' and saves the result to a dataset named 'outdata'.

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;

The **PROC STDIZE** procedure is used to find out percentiles in a tabular format. You don't need to specify prefix as original variable names will be used in the output dataset.

proc stdize data=sashelp.class PctlMtd=ORD_STAT outstat=outdata pctlpts=5,95; var height weight; run;

Share Share Tweet