BINNING Procedure

Example 5.1 Quantile Binning

(View the complete code for this example.)

The following DATA step generates 1,000,000 observations of an ID variable (id) and two continuous variables (x1–x2). The mylib CAS library reference enables your client machine to communicate with the CAS session. These statements assume that your CAS engine libref is named mylib, but you can substitute any appropriately defined CAS engine libref.

data mylib.ex1;
   length id 8;
   call streaminit(12345);
   do id=1 to 1000000;
      x1 = rand("Uniform");
      x2 = rand("Uniform") * 10;
      output;
   end;
run;

The following statements demonstrate how to use PROC BINNING to perform the quantile binning:

proc binning data=mylib.ex1 numbin=10 method=quantile;
   input x1-x2;
   output out=mylib.out1;
run;

The DATA= option specifies the input data table. The NUMBIN= option requests that 10 bins be created for all binning variables. The METHOD= option requests that the quantile binning method be used. The INPUT statement names two continuous variables (x1–x2) as input variables for binning. The OUTPUT statement creates an OUTPUT data table to contain the results of PROC BINNING.

The "Bin Details" table in Quantile Binning shows the binning variable, bin ID, bin lower bound, bin upper bound, bin width, number of observations in that bin, and some statistics of that bin (such as mean, standard deviation, minimum, and maximum). When the binning method is quantile, PROC BINNING assigns the same number of observations to each bin for the input variables if possible.

Output 5.1.1: Bin Details

The BINNING Procedure

Bin Details
VariableBin IDLower
Bound
Upper
Bound
Bin
Width
Number of
Observations
MeanStandard
Deviation
MinimumMaximum
x1Missing   0    
 1-Infty0.0995 999990.04970.0288795E-90.0995
 20.09950.19980.10031000000.14960.02890.09950.1998
 30.19980.29990.10011000000.24980.02890.19980.2999
 40.29990.39970.09981000000.34980.02890.29990.3997
 50.39970.49990.10021000000.44970.02900.39970.4999
 60.49990.59970.09981000000.54980.02880.49990.5997
 70.59970.69940.09971000000.64950.02870.59970.6994
 80.69940.79960.10021000000.74950.02890.69940.7996
 90.79960.89990.10031000000.84970.02900.79960.8999
 100.8999Infty 1000010.94990.02890.89991.0000
x2Missing   0    
 1-Infty1.0047 999990.50340.2895975E-81.0047
 21.00472.00571.00111000001.50410.28891.00472.0057
 32.00573.00110.99541000002.50540.28742.00573.0011
 43.00114.00501.00391000003.50410.28983.00114.0050
 54.00505.00691.00191000014.50510.28914.00505.0069
 65.00696.00460.9977999995.50680.28825.00696.0046
 76.00467.00390.9993999996.50560.28846.00467.0039
 87.00397.99890.99501000017.50020.28707.00397.9989
 97.99899.00171.00281000008.50100.28987.99899.0016
 109.0017Infty 1000019.50100.28819.001710.000


Last updated: September 22, 2026