The HPBIN Procedure
Example 3.1 Bucket Binning
The following DATA step creates the SAS data set as the input for the example:
data ex12;
length id 8;
do id=1 to 1000;
x1 = ranuni(101);
x2 = 10*ranuni(201);
x3 = 100*ranuni(301);
output;
end;
run;
The following statements show the basic usage:
proc hpbin data=ex12 output=out numbin=10 bucket ;
input x1-x3;
run;
proc print data=out(obs=10); run;
PROC HPBIN generates several ODS tables, which are shown in Figure 3 through Figure 4.
Figure 3: PROC HPBIN Binning Information Display
The HPBIN Procedure
| Binning Information | |
|---|---|
| Method | Bucket Binning |
| Number of Bins Specified | 10 |
| Number of Variables | 3 |
Figure 4: PROC HPBIN Mapping Table
| Mapping | ||||
|---|---|---|---|---|
| Variable | Binned Variable | Range | Frequency | Proportion |
| x1 | BIN_x1 | x1 < 0.0999254969 | 108 | 0.10800000 |
| 0.0999254969 <= x1 < 0.1993986319 | 94 | 0.09400000 | ||
| 0.1993986319 <= x1 < 0.2988717668 | 90 | 0.09000000 | ||
| 0.2988717668 <= x1 < 0.3983449018 | 95 | 0.09500000 | ||
| 0.3983449018 <= x1 < 0.4978180367 | 90 | 0.09000000 | ||
| 0.4978180367 <= x1 < 0.5972911716 | 115 | 0.11500000 | ||
| 0.5972911716 <= x1 < 0.6967643066 | 116 | 0.11600000 | ||
| 0.6967643066 <= x1 < 0.7962374415 | 105 | 0.10500000 | ||
| 0.7962374415 <= x1 < 0.8957105765 | 106 | 0.10600000 | ||
| 0.8957105765 <= x1 | 81 | 0.08100000 | ||
| x2 | BIN_x2 | x2 < 1.0215392099 | 99 | 0.09900000 |
| 1.0215392099 <= x2 < 2.0154070426 | 110 | 0.11000000 | ||
| 2.0154070426 <= x2 < 3.0092748753 | 99 | 0.09900000 | ||
| 3.0092748753 <= x2 < 4.003142708 | 85 | 0.08500000 | ||
| 4.003142708 <= x2 < 4.9970105407 | 109 | 0.10900000 | ||
| 4.9970105407 <= x2 < 5.9908783734 | 98 | 0.09800000 | ||
| 5.9908783734 <= x2 < 6.9847462061 | 100 | 0.10000000 | ||
| 6.9847462061 <= x2 < 7.9786140388 | 94 | 0.09400000 | ||
| 7.9786140388 <= x2 < 8.9724818715 | 112 | 0.11200000 | ||
| 8.9724818715 <= x2 | 94 | 0.09400000 | ||
| x3 | BIN_x3 | x3 < 10.173596707 | 97 | 0.09700000 |
| 10.173596707 <= x3 < 20.14299647 | 97 | 0.09700000 | ||
| 20.14299647 <= x3 < 30.112396232 | 106 | 0.10600000 | ||
| 30.112396232 <= x3 < 40.081795994 | 94 | 0.09400000 | ||
| 40.081795994 <= x3 < 50.051195757 | 102 | 0.10200000 | ||
| 50.051195757 <= x3 < 60.020595519 | 99 | 0.09900000 | ||
| 60.020595519 <= x3 < 69.989995281 | 107 | 0.10700000 | ||
| 69.989995281 <= x3 < 79.959395044 | 92 | 0.09200000 | ||
| 79.959395044 <= x3 < 89.928794806 | 91 | 0.09100000 | ||
| 89.928794806 <= x3 | 115 | 0.11500000 | ||
In this example, PROC HPBIN also generates the output table. The first 10 observations of the table are shown in Figure 5.
Figure 5: First 10 Observations in the Output Table
| Obs | BIN_x1 | BIN_x2 | BIN_x3 |
|---|---|---|---|
| 1 | 7 | 10 | 4 |
| 2 | 2 | 1 | 9 |
| 3 | 9 | 8 | 1 |
| 4 | 8 | 8 | 10 |
| 5 | 2 | 8 | 7 |
| 6 | 1 | 6 | 7 |
| 7 | 7 | 9 | 6 |
| 8 | 7 | 5 | 1 |
| 9 | 1 | 4 | 1 |
| 10 | 7 | 9 | 1 |
Last updated: March 06, 2023