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
TargetNumber of ObsNumber of Samples
 27928
MGR76776
OFFICE94894
OTHER2388238
PROFEXE1276128
SALES10911
SELF19319


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

ObsJOBREASONLOANVALUEDELINQDEROG_PartInd_
1OtherHomeImp110039025000
2OtherHomeImp130068400200
3OtherHomeImp150016700000
4  1500...0
5OfficeHomeImp1700112000000
6OtherHomeImp170040320000
7OtherHomeImp180057037230
8OtherHomeImp180043034000
9OtherHomeImp200046740200
10SalesHomeImp200062250000
11  2000...0
12OfficeHomeImp200029800100
13OtherHomeImp200055000000
14Mgr 200087400000
15OtherHomeImp210083850100


Last updated: March 06, 2023