BINNING Procedure
Example 5.3 Bucket Binning and Weight-of-Evidence Computation
(View the complete code for this example.)
The following DATA step generates a data table that contains 10 observations of a target variable (y), three continuous variables (x0–x2), and some other variables. The mylib CAS library reference enables your client machine to communicate with the CAS session.
data mylib.ex3;
input cl1 $ x0 x1 x2 y $ freq id;
datalines;
a 2 . 7 n 2 1
a 2 2 6 . 3 2
a 3 0 1 o 0 3
c 2 3 7 y . 4
c 2 . 4 n -5 5
a 3 6 7 n 3 6
b 1 4 4 y 4 7
b 2 5 6 y 3 8
b 1 6 4 o 1 9
b 2 3 2 n 3 10
;
The following statements show how you can use the BINNING procedure to perform bucket binning and compute the WOE and the information value (IV):
proc binning data=mylib.ex3 numbin=5 woe;
input x1/numbin=4;
input x2;
target y/event="y";
output out=mylib.out3;
run;
The DATA= option specifies the input data table. The WOE option enables computation of the weight of evidence and information values with WOEADJUST=0.5 by default. The first INPUT statement names one continuous variable (x1) as the first input variable for binning with four bins. The second INPUT statement names another continuous variable (x2) as the second input variable for binning with five bins, as specified in the NUMBIN= global option. The TARGET statement names the variable (y) that PROC BINNING uses to calculate the weight of evidence, and the EVENT= option specifies the target event category in a quoted string. The OUTPUT statement creates an OUTPUT data table to contain the results of PROC BINNING.
The preceding statements generate Output 5.3.1 through Output 5.3.2.
Output 5.3.1: Bin Details
| Bin Details | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Variable | Bin ID | Lower Bound | Upper Bound | Bin Width | Number of Observations | Mean | Standard Deviation | Minimum | Maximum | Event Count | Weight of Evidence | Information Value |
| x1 | Missing | 2 | 0 | 0.9163 | 0.3054 | |||||||
| 1 | -Infty | 1.5000 | 1 | 0 | 0 | 0 | 0 | 0.4055 | 0.0676 | |||
| 2 | 1.5000 | 3 | 1.5000 | 1 | 2 | 2 | 2 | 0 | . | . | ||
| 3 | 3 | 4.5000 | 1.5000 | 3 | 3.3333 | 0.5774 | 3 | 4 | 2 | -1.386 | 0.6931 | |
| 4 | 4.5000 | Infty | 3 | 5.6667 | 0.5774 | 5 | 6 | 1 | 0 | 0 | ||
| x2 | Missing | 0 | 0 | . | . | |||||||
| 1 | -Infty | 2.2000 | 2 | 1.5000 | 0.7071 | 1 | 2 | 0 | 0.9163 | 0.3054 | ||
| 2 | 2.2000 | 3.4000 | 1.2000 | 0 | 0 | . | . | |||||
| 3 | 3.4000 | 4.6000 | 1.2000 | 3 | 4 | 0 | 4 | 4 | 1 | 0 | 0 | |
| 4 | 4.6000 | 5.8000 | 1.2000 | 0 | 0 | . | . | |||||
| 5 | 5.8000 | Infty | 5 | 6.6000 | 0.5477 | 6 | 7 | 2 | -0.693 | 0.2310 | ||
Output 5.3.2: Variable Information Value
| Variable Information Value | |
|---|---|
| Variable | Information Value |
| x1 | 1.0662 |
| x2 | 0.5365 |