BINNING Procedure

Bucket Binning

(View the complete code for this example.)

Note: Input data must be in a CAS table that is accessible in your CAS session. You must refer to this table by using a two-level name. The first level must be a CAS engine libref, and the second level must be the table name. For more information, see the sections Using CAS Sessions and CAS Engine Librefs and Loading a SAS Data Set onto a CAS Server in Chapter 2, Shared Concepts.

The following DATA step creates the data table mylib.bucket, which consists of 1,000 observations of an ID variable (id) and three continuous variables (x1–x3), in your CAS session:

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

These statements assume that your CAS engine libref is named mylib, but you can substitute any appropriately defined CAS engine libref.

The following statements show how you can use the BINNING procedure to perform bucket binning:

proc binning data=mylib.bucket numbin=10 method=bucket;
   input x1-x3;
   output out=mylib.out;
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 bucket binning method be used. The INPUT statement names three continuous variables (x1–x3) as input variables for binning. The OUTPUT statement creates an OUTPUT data table to contain the results of PROC BINNING.

Figure 1 displays the "Bin Details" table. This table 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).

Figure 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.1004 970.05530.02790.00050.0985
 20.10040.20030.09991060.14900.02960.10060.1980
 30.20030.30020.0999920.24970.02670.20120.2987
 40.30020.40010.0999990.35290.02660.30240.3993
 50.40010.50000.0999890.44220.02880.40070.4995
 60.50000.59980.09991070.54370.02860.50020.5931
 70.59980.69970.0999950.64710.02940.60130.6961
 80.69970.79960.0999930.75210.03000.70030.7984
 90.79960.89950.09991010.84460.02720.80100.8994
 100.8995Infty 1210.94520.02880.89970.9994
x2Missing   0    
 1-Infty1.0044 970.48270.27990.00570.9973
 21.00442.00310.99871041.52210.28211.00671.9993
 32.00313.00180.99871112.51160.29722.00792.9934
 43.00184.00060.9987953.50630.28803.00243.9980
 54.00064.99930.9987914.48070.30024.01134.9960
 64.99935.99800.9987775.53510.28165.01045.9959
 75.99806.99670.99871006.51700.27836.01546.9882
 86.99677.99540.99871117.44210.27227.00027.9516
 97.99548.99410.99871108.41270.28158.00268.9929
 108.9941Infty 1049.50130.28059.01249.9928
x3Missing   0    
 1-Infty10.192 1014.84743.10680.216010.190
 210.19220.1679.97579414.8802.995510.21120.084
 320.16730.1439.975710425.1733.039320.20730.141
 430.14340.1199.97578534.9932.922130.54240.059
 540.11950.0959.97579544.8853.029740.31249.732
 650.09560.0709.975710454.5772.866450.09759.895
 760.07070.0469.97579464.9632.788960.13969.596
 870.04680.0229.975712475.1662.651570.06579.945
 980.02289.9989.97578584.9912.826980.14289.789
 1089.998Infty 11494.8532.906690.04699.973


Last updated: September 22, 2026