BINNING Procedure

Example 5.5 Tree-Based Binning

(View the complete code for this example.)

The following statements show how you can use the BINNING procedure to perform tree-based binning:

data mylib.hmeq;
    set sampsio.hmeq;
run;
proc binning data=mylib.hmeq method=tree;
 target bad/level=int;
 input mortdue/level = int;
 input job/ level = nom;
 output outlevelbinmap=mylib.outlevel;
run;

proc print data=mylib.outlevel;
run;

The DATA= option specifies the input data table. The METHOD= option requests that tree-based binning method be used. The TARGET statement specifies bad as the target variable and requests that it be treated as an interval variable. The first INPUT statement names one variable, mortdue, and requests that it be treated as interval. The second INPUT statement names one variable, job, and requests that it be treated as nominal.

Output 5.5.1 shows the "Bin Details" table. Compared to the "Bin Details" tables in previous examples, this table has an extra column, "N Levels". The reason is that other binning methods can handle only interval variables, but tree-based binning can handle both interval and nominal variables. The "N Levels" column shows the number of levels of this variable that this bin contains. As a result, for interval variables, this column is empty.

Output 5.5.1: Bin Details

The BINNING Procedure

Bin Details
VariableBin IDLower
Bound
Upper
Bound
Bin
Width
N LevelsNumber of
Observations
MeanStandard
Deviation
MinimumMaximum
MORTDUEMissing    518    
 1-Infty37837  933237019087.0206337750
 2378377361135774 2309564169712.43784373600
 37361110541031799 1283874489032.373624105328
 410541014515839749 57512412711706105422145127
 5145158Infty  34219140648765145324399550
JOBMissing   1279    
 1   2302    
 2   1767    
 3   12388    
 4   11276    
 5   1948    


Output 5.5.2 shows the "Transformation Information" table.

Output 5.5.2: Transformation Information

Transformation Information
VariableNN MissN BinsImportanceRelative
Importance
MORTDUE544251868.69770.5053
JOB5681279617.2141


Output 5.5.3 shows the "Output Bin Mapping" data table.

Output 5.5.3: Output Bin Mapping Data Table

ObsVariableLevelBinId
1JOB 0
2JOBSales1
3JOBSelf1
4JOBMgr2
5JOBOther3
6JOBProfExe4
7JOBOffice5


Last updated: September 22, 2026