PCTL Function

Returns the percentile that corresponds to the percentage.

Category: Descriptive Statistics
Returned data type: DOUBLE

Syntax

Arguments

n

is a digit from 1 to 5 that specifies the definition of the percentile to be computed.

Default definition 5
Data type DOUBLE
See QNTLDEF= (alias PCTLDEF=) descriptions in the table “Methods for Computing Quantile Statistics” in the Base SAS Procedures Guide.

percentage

specifies the percentile to be computed.

Data type DOUBLE
Tip percentage is numeric where, 0less than or equal topercentageless than or equal to100.

expression

specifies any valid expression that evaluates to a numeric value, whose value is computed in the percentile calculation.

Data type DOUBLE
See <sql-expression>
FedSQL Expressions

Details

The PCTL function returns the percentile of the non-null or nonmissing values corresponding to the percentage. If percentage is null or missing, less than zero, or greater than 100, the PCTL function generates an error message.

Example

The following statements illustrate the PCTL function:
Description
Statement
Result
Lower quartile
select pctl(25,2,4,1,3);
1.5
Percentile definition two
select pctl2(25,2,4,1,3);
1
Lower tertile
select pctl(100/3,2,4,1,3);
2
Percentile definition three
select pctl3(100/3,2,4,1,3);
2
Median
select pctl(50,2,4,1,3);
2.5
Upper tertile
select pctl(200/3,2,4,1,3);
3
Upper quartile
select pctl(75,2,4,1,3);
3.5
Last updated: February 23, 2017