IMSTAT Procedure (Analytics)

Example 1: Calculating Percentiles and Quartiles

Details

If you specify the PERCENTILE statement without variables or options, you obtain results for the 25th, 50th, and 75th percentile. These are also known as the first quartile, the median, and the third quartile. This is done for all numeric non-CLASS variables in the table.
This PROC IMSTAT demonstrates the default behavior for calculating percentiles for a single variable and then demonstrates using GROUPBY= variables and generating results for nonstandard percentiles.

Program

libname example sasiola host="grid001.unx.sas.com" port=10010 tag='hps';

data example.prdsale; set sashelp.prdsale; run;

proc imstat data=example.prdsale;
    percentile actual; 1
run;
    percentile actual / groupby=(region division); 2
run;
    percentile actual / values=(3 5 10 90 95 97); 3
quit;

Program Description

  1. This PERCENTILE statement generates the default output for the Actual variable.
  2. The quartiles for the Actual variable are calculated for the groups of Region and Division.
  3. The VALUES= option is used to specify the percentiles to calculate.

Output

The following results include the column that is named Converged. This column indicates whether the iterative percentile algorithm converged for the variable and percentile. It is possible that some percentiles can fail to converge while others do converge. The converged percentiles match those computed with the UNIVARIATE or MEANS procedures using their default definition of a quantile.
Default Output for a Single Variable
Percentiles and quartiles for Actual
Results for Actual Grouped by Region and Division
Percentiles and quartiles for a single value with a GROUPBY= option
Results for a Single Variable Using the VALUES= Option
Percentiles and quartiles for a single value using the VALUES= option