PARTITION Procedure

Example 24.1 Simple Random Sampling

(View the complete code for this example.)

This example demonstrates how to use PROC PARTITION to perform simple random sampling on the mylib.hmeq data table.

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 the sampling:

proc partition data=mylib.hmeq samppct=10 seed=10 nthreads=1;
   output out=mylib.out2 copyvars=(job reason loan value delinq derog);
   display 'SRSFreq';
run;

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

The SAMPPCT=10 option requests that 10% of the input data be sampled. The OUTPUT statement requests that the sampled data be stored in a table named mylib.out2, and the COPYVARS= option lists the variables to be copied from mylib.hmeq to mylib.out2. The DISPLAY statement requests that the SRSFreq ODS table be displayed.

Output 24.1.1 shows the number of observations in the mylib.hmeq data table and the number of samples in the mylib.out2 data table .

Output 24.1.1: Frequency Information Table

The PARTITION Procedure

Simple Random
Sampling Frequency
Number
of Obs
Number
of Samples
5960596


Output 24.1.2 shows the sample data, which are stored in the mylib.out2 data table.

Output 24.1.2: Sample Data

ObsJOBREASONLOANVALUEDELINQDEROG
1OtherHomeImp29006799603
2OtherHomeImp30003300010
3OfficeHomeImp30005640000
4OfficeHomeImp36006398900
5OfficeHomeImp40006177700
6OtherHomeImp40001602010
7MgrHomeImp4000718652.
8ProfExeDebtCon41006379740
9OtherHomeImp43007985200
10  440060250..
11ProfExeDebtCon45008700040
12SelfHomeImp50005344800
13OtherHomeImp50005083000
14 DebtCon500077908..
15OtherHomeImp50004628100
16ProfExeHomeImp510011534100
17ProfExeHomeImp510012138200
18OtherHomeImp52007700010
19OfficeHomeImp530050673..
20  540075254..


Last updated: September 22, 2026