PARTITION Procedure

Example 24.3 Oversampling

(View the complete code for this example.)

This example demonstrates how to use PROC PARTITION to perform oversampling; it uses the same data table as in Example 24.1.

You can load the sampsio.hmeq data set into your CAS session by naming your CAS engine libref in the first statement of the following DATA step. This DATA step assumes that your CAS engine libref is named mylib, but you can substitute any appropriately defined CAS engine libref.

data mylib.hmeq;
   set sampsio.hmeq;
run;

The following statements perform oversampling:

proc partition data=mylib.hmeq samppctevt=90 eventprop=0.5
               event="1" seed=10 nthreads=1;
   by BAD;
   ods output OVERFREQ=outFreq;
   output out=mylib.out4 copyvars=(job loan value delinq derog)
          freqname=_Freq2_;
run;

proc print data=mylib.out4(obs=20);
run;

The EVENTPROP=0.5 option specifies that 50% of the sample are rare events. The SAMPPCTEVT=90 option requests that 90% of the rare events be sampled. The EVENT="1" option specifies that the second level of the variable BAD corresponds to a rare event. The OUTPUT statement requests that the sampled data be stored in a table named mylib.out4, specifies the variables to be transferred from the input data table, requests that the _Freq_ column be renamed to _Freq2_.

Output 24.3.1 shows the number of observations in the sample and in each level of the BY variable BAD in the mylib.out4 data table.

Output 24.3.1: Frequency Information Table

The PARTITION Procedure

Oversampling Frequency
IndexBADNumber
of Obs
Number
of Samples
0047711070
1111891070


Output 24.3.2 shows the first 20 output sample observations in the mylib.out4 data table; the _Freq2_ column shows the ratio of target level’s proportion in the population to its proportion in the sample.

Output 24.3.2: Output Data Table

ObsJOBLOANVALUEDELINQDEROG_Freq2_
1Other110039025000.39899
2Other130068400200.39899
3Other150016700000.39899
4 1500...0.39899
5Other170040320000.39899
6Other180057037230.39899
7Other180043034000.39899
8Other200046740200.39899
9Sales200062250000.39899
10 2000...0.39899
11Office200029800100.39899
12Other200055000000.39899
13Mgr200087400001.60101
14Other210083850100.39899
15Other220034687100.39899
16Mgr2200102600620.39899
17 2200...0.39899
18Other230040150000.39899
19Other230046200100.39899
20Mgr240040800000.39899


Last updated: September 22, 2026