QTRSELECT Procedure

Example 28.2 Growth Charts for Body Mass Index

(View the complete code for this example.)

This example is modeled on an example in the section "Getting Started: QUANTREG Procedure" in the SAS/STAT User's Guide. This example highlights the use of the QTRSELECT procedure for multiple-level quantile regression by creating growth charts for men’s body mass index (BMI).

BMI, which is defined as the ratio of weight (kg) to squared height (msquared), is a standard measure for categorizing individuals as overweight or underweight. The percentiles of BMI for specified ages are of particular interest. This example draws smooth BMI quantile curves conditional on Age, which can serve as BMI growth charts in medical diagnoses to identify BMI percentiles for subjects.

The Sashelp.BMIMen data set records 1999–2000 and 2001–2002 survey results for men’s BMI. These survey results are published by the National Center for Health Statistics. The data set contains 3,264 observations for two variables, BMI and Age.

The following statements display the variables in the data set. Output 28.2.1 shows the results.

proc contents varnum data=sashelp.BMIMen;
   ods select position;
run;

Output 28.2.1: Sashelp.BMIMen Data Set

The CONTENTS Procedure

Variables in Creation Order
#VariableTypeLen
1AgeNum8
2BMINum8


You can load the Sashelp.BMIMen data set into your CAS session by specifying your CAS engine libref in the first statement in the following DATA step:

   data mylib.BMIMen;
      set sashelp.BMIMen;
      SqrtAge = sqrt(Age);
      InveAge = 1/Age;
      LogBMI  = log(BMI);
   run;

The logarithm of BMI is used as the response. The following statements fit quantile regression models for the mylib.BMIMen data table at 10 quantile levels:

%let quantile=0.03 0.05 0.1 0.25 0.5 0.75 0.85 0.90 0.95 0.97;
%let nq=10;

proc qtrselect data=mylib.BMIMen;
   model logBMI = InveAge SqrtAge Age SqrtAge*Age Age*Age Age*Age*Age
         / quantile=&quantile;
   output out=mylib.BMIOut copyvars=(BMI Age) pred=P_LogBMI;
run;

The OUTPUT statement outputs the mean predicted quantiles for the 10 specified quantile levels. The PRED= option in the OUTPUT statement specifies the variable names for the quantile predictions. For example, p1 is for quantile level 0.03, and p2 is for quantile level 0.05.

The following statements define and apply a SAS macro function to create a quantile curves plot for the mylib.BMIOut data table:

%let BMIcolor=red olive orange blue brown gray violet black gold green;

%macro plotBMI;
   data BMIPred;
      set mylib.BMIOut;
      %do j=1 %to &nq;
         predBMI&j = exp(P_LogBMI&j);
      %end;
      label %do j=1 %to &nq;
               predBMI&j=%qscan(&quantile,&j,%str( ))
            %end;;
   run;

   proc sort data=BMIPred;
      by Age;
   run;

   proc sgplot data=BMIPred;
      %do j=1 %to &nq;
         series y=predBMI&j x=Age/lineattrs=(thickness=2
         color=%qscan(&BMIcolor,&j,%str( )));
      %end;
      scatter y=BMI x=Age/markerattrs=(size=5);
   run;
%mend;

%plotBMI;

Output 28.2.2 shows the BMI quantile curves, which can serve as BMI growth charts. For example, the percentiles of any observations (small blue circles) that are located between the top 0.95 quantile (gold) curve and the 0.97 quantile (green) curve are between the 95th percentile and the 97th percentile. By using this rule, you can measure the percentile range for any observations of interest.

Output 28.2.2: Growth Chart for Body Mass Index

Growth Chart for Body Mass Index


Last updated: September 22, 2026