The HPSAMPLE Procedure
Example 8.2 Using PROC HPSAMPLE to Perform Stratified Sampling
This example uses the same data set as is used in Example 8.1. This example demonstrates how to use PROC HPSAMPLE to perform stratified sampling.
proc hpsample data=sampsio.hmeq out=out2 samppct=10 seed=13579 partition;
var loan value delinq derog;
class job reason;
target job;
run;
proc print data=out2(obs=15);
run;
Output 8.2.1 shows the frequency information for each level of target variable job in the data set Sampsio.Hmeq and in the sample.
Output 8.2.1: Frequency Table
The HPSAMPLE Procedure
| One Target Stratified Sampling Frequency Table | ||
|---|---|---|
| Target | Number of Obs | Number of Samples |
| 279 | 28 | |
| MGR | 767 | 76 |
| OFFICE | 948 | 94 |
| OTHER | 2388 | 238 |
| PROFEXE | 1276 | 128 |
| SALES | 109 | 11 |
| SELF | 193 | 19 |
Output 8.2.2 shows the first 15 output sample observations that contain "_PARTIND_", which indicates whether the observation is selected for the sample (1) or not (0).
Output 8.2.2: Sample Output with Partition Indicator
| Obs | JOB | REASON | LOAN | VALUE | DELINQ | DEROG | _PartInd_ |
|---|---|---|---|---|---|---|---|
| 1 | Other | HomeImp | 1100 | 39025 | 0 | 0 | 0 |
| 2 | Other | HomeImp | 1300 | 68400 | 2 | 0 | 0 |
| 3 | Other | HomeImp | 1500 | 16700 | 0 | 0 | 0 |
| 4 | 1500 | . | . | . | 0 | ||
| 5 | Office | HomeImp | 1700 | 112000 | 0 | 0 | 0 |
| 6 | Other | HomeImp | 1700 | 40320 | 0 | 0 | 0 |
| 7 | Other | HomeImp | 1800 | 57037 | 2 | 3 | 0 |
| 8 | Other | HomeImp | 1800 | 43034 | 0 | 0 | 0 |
| 9 | Other | HomeImp | 2000 | 46740 | 2 | 0 | 0 |
| 10 | Sales | HomeImp | 2000 | 62250 | 0 | 0 | 0 |
| 11 | 2000 | . | . | . | 0 | ||
| 12 | Office | HomeImp | 2000 | 29800 | 1 | 0 | 0 |
| 13 | Other | HomeImp | 2000 | 55000 | 0 | 0 | 0 |
| 14 | Mgr | 2000 | 87400 | 0 | 0 | 0 | |
| 15 | Other | HomeImp | 2100 | 83850 | 1 | 0 | 0 |
Last updated: March 06, 2023