SMOTE Procedure
Getting Started: SMOTE Procedure
Note: Input data must be in a CAS table that is accessible in your CAS session. You must refer to this table by using a two-level name. The first level must be a CAS engine libref, and the second level must be the table name. For more information, see the sections Using CAS Sessions and CAS Engine Librefs and Loading a SAS Data Set onto a CAS Server in Chapter 2, Shared Concepts.
This example shows how to use the SMOTE procedure to analyze and augment the Cars data set in the Sashelp library. The Cars data set contains 428 observations and 15 variables. The variables MPG_City, Weight, and EngineSize are three highly correlated variables that this example uses. The following DATA step creates the input data table mylib.cars in your CAS session. These statements assume that your CAS engine libref is named mylib, but you can substitute any appropriately defined CAS engine libref.
data mylib.cars;
set sashelp.cars;
run;
The following statements analyze the correlations among pairs of the three variables in the original data set:
ods graphics on;
title "Pearson Correlation and Matrix Plot of Original Data";
proc corr data=mylib.cars noprob plots=matrix(hist);
var MPG_City Weight EngineSize;
ods select PearsonCorr MatrixPlot;
run;
Figure 1 shows that the Pearson correlation between MPG_City and Weight is –0.73797, between MPG_City and EngineSize is –0.70947, and between Weight and EngineSize is 0.80787.
Figure 1: Pearson Correlation of the Original Data
| Pearson Correlation and Matrix Plot of Original Data |
| Pearson Correlation Coefficients, N = 428 | |||||
|---|---|---|---|---|---|
| MPG_City | Weight | EngineSize | |||
| 1.00000 | -0.73797 | -0.70947 | ||
| -0.73797 | 1.00000 | 0.80787 | ||
| -0.70947 | 0.80787 | 1.00000 | ||
Figure 2 shows the marginal and bivariate distributions of the original data.
Figure 2: Scatter Plot Matrix of the Original Data

The following PROC SMOTE statements generate synthetic observations by using the SMOTE method and save the synthetic observations in the mylib.out data table:
proc smote data=mylib.cars seed=123;
input MPG_City Weight EngineSize/level=interval;
input make type/level=nominal;
sample k=3 numSamples=500;
output out=mylib.out;
run;
Figure 3 shows the number of observations in the sample that are read and used for the analysis, as well as the number of samples that are generated.
Figure 3: Number of Observations
| Number of Observations | |
|---|---|
| Number of Observations Read | 428 |
| Number of Observations Used | 428 |
| Number of Synthetic Observations Generated | 500 |
The interval and nominal input variables are specified by using the INPUT statements. In the SAMPLE statement, you specify the number of nearest neighbors for the SMOTE method in the K= option, and you specify the number of synthetic observations to generate in the NUMSAMPLES= option. The OUTPUT statement specifies the table to use for output results.
Figure 4 shows the settings for the SMOTE model and output.
Figure 4: Model Information
| Model Information | |
|---|---|
| Number of Synthetic Samples to Generate | 500 |
| Number of Nearest Neighbors to Use in Calculation | 3 |
| Seed Used for Random Number Generator | 123.0 |
The correlation of the synthetic generated data is analyzed by using the following PROC CORR statements. It is found that PROC SMOTE generates synthetic data whose correlation patterns are very similar to those of the original data.
title "Pearson Correlation and Matrix Plot of Synthetic Data";
proc corr data=mylib.out noprob plots=matrix(hist);
var MPG_City Weight EngineSize;
ods select PearsonCorr MatrixPlot;
run;
Figure 5 and Figure 6 show the Pearson correlation and the scatter plot matrix of the synthetic data, respectively.
Figure 5: Pearson Correlation of the Synthetic Data
| Pearson Correlation and Matrix Plot of Synthetic Data |
| Pearson Correlation Coefficients, N = 500 | |||
|---|---|---|---|
| MPG_City | Weight | EngineSize | |
| MPG_City | 1.00000 | -0.83987 | -0.78724 |
| Weight | -0.83987 | 1.00000 | 0.87351 |
| EngineSize | -0.78724 | 0.87351 | 1.00000 |
Figure 6: Scatter Plot Matrix of the Synthetic Data
