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

The CORR Procedure

Pearson Correlation Coefficients, N = 428
 MPG_CityWeightEngineSize
MPG_City
MPG (City)
1.00000-0.73797-0.70947
Weight
Weight (LBS)
-0.737971.000000.80787
EngineSize
Engine Size (L)
-0.709470.807871.00000


Figure 2 shows the marginal and bivariate distributions of the original data.

Figure 2: Scatter Plot Matrix of the Original Data

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

The SMOTE Procedure

Number of Observations
Number of Observations Read428
Number of Observations Used428
Number of Synthetic Observations Generated500


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 Generate500
Number of Nearest Neighbors to Use in Calculation3
Seed Used for Random Number Generator123.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

The CORR Procedure

Pearson Correlation Coefficients, N = 500
 MPG_CityWeightEngineSize
MPG_City1.00000-0.83987-0.78724
Weight-0.839871.000000.87351
EngineSize-0.787240.873511.00000


Figure 6: Scatter Plot Matrix of the Synthetic Data

 Scatter Plot Matrix of the Synthetic Data


Last updated: August 06, 2026