TABULARGAN Procedure
Getting Started: TABULARGAN Procedure
This example shows how to use the TABULARGAN procedure to analyze and augment the Fish data set in the Sashelp library. The Fish data set contains 159 observations and seven variables. Among these variables, Species is a nominal variable that contains the names of various fish species. The other six variables are interval variables that contain statistics of the fish: height, weight, width, and three measures of length. The following DATA step creates the input data table mylib.fish in your SAS library. These statements assume that your SAS libref is named mylib, as in the section Using SAS Viya Workbench, but you can substitute any appropriately defined SAS libref.
data mylib.fish;
set sashelp.fish;
run;
The following PROC TABULARGAN statement trains a tabular GAN model and saves the trained model in an analytic store:
proc tabulargan data=mylib.fish seed=123 numSamples=10 useGPU;
input weight length1 length2 length3/level=interval;
input species/level=nominal;
aeoptimization numEpochs=3;
ganoptimization numEpochs=5;
train miniBatchSize=50;
savestate rstore=mylib.astore;
output out=mylib.out;
run;
The interval and nominal input variables are determined using the INPUT statements. You specify the number of epochs for training the autoencoder models in the AEOPTIMIZATION statement. Similarly, you specify the number of epochs for training the generative adversarial network (GAN) models in the GANOPTIMIZATION statement. Note that the typical number of epochs for the autoencoder and GAN models should be greater than 100 for proper model training. The appropriate number of epochs, specified in the NUMEPOCHS= option, should be found for each use case. The SAVESTATE statement specifies the table to use for saving the trained model, and the OUTPUT statement specifies the table to use for output results.
Figure 1 shows the iteration history, including the autoencoder loss value and the generator and discriminator loss values for each epoch of training.
Figure 1: Iteration History
| Iteration History | |||
|---|---|---|---|
| Epoch Number | Autoencoder Loss | Generator Loss | Discriminator Loss |
| 1 | 0.345445 | . | . |
| 2 | 0.282496 | . | . |
| 3 | 0.233644 | . | . |
| 1 | . | 1.957608 | 0.061005 |
| 2 | . | 1.930210 | -0.032211 |
| 3 | . | 1.951218 | 0.016106 |
| 4 | . | 1.956728 | -0.006330 |
| 5 | . | 1.991888 | 0.003569 |
Figure 2 shows the number of observations that are read and the number of observations that are used. Because the mylib.fish data table contains missing values, the number of observations read does not equal the number of observations used in this example. When the input data table contains missing values, PROC TABULARGAN ignores the observations (rows) that have missing values in the input data table and does not use them in the analysis.
Figure 2: Number of Observations
| Number of Observations | |
|---|---|
| Number of Observations Read | 159 |
| Number of Observations Used | 158 |
Figure 3 shows the values of the parameters that are used in the tabular GAN model.
Figure 3: Model Information
| Model Information | |
|---|---|
| Generator Embedding Dimension | 128 |
| Number of Observations in One Minibatch | 50 |
| Number of Observations Group Together in Applying the Discriminator | 10 |
| Weight for Regularizing the Discriminator | 10 |
| Exponential Decay Rate for the First-Moment Estimates for the Autoencoder's Optimizer | 0.9 |
| Exponential Decay Rate for the Second-Moment Estimates for the Autoencoder's Optimizer | 0.999 |
| Learning Rate for the Autoencoder's Optimizer | 0.001 |
| Number of Epochs for the Autoencoder's Training | 3 |
| Weight Decay for the Autoencoder's Optimizer | 1E-8 |
| Exponential Decay Rate for the First-Moment Estimates to Optimize GAN | 0.5 |
| Exponential Decay Rate for the Second-Moment Estimates to Optimize GAN | 0.9 |
| Learning Rate for the GAN Optimizer | 0.00002 |
| Number of Epochs for the GAN Training | 5 |
| Weight Decay for the Generator's Optimizer | 0.0001 |
| Weight Decay for the Discriminator's Optimizer | 1E-6 |
| Seed for Random Initialization | 123 |
| Whether to Use Log Frequency of Categorical Levels in the Conditional Sampling | True |
Figure 4 shows the level names and frequencies of the nominal variable Species.
Figure 4: Level Frequencies of Nominal Variables
| Level Frequencies for Nominal Variables | ||
|---|---|---|
| Variable Name | Level | Frequency |
| Species | Bream | 34 |
| Species | Parkki | 11 |
| Species | Perch | 56 |
| Species | Pike | 17 |
| Species | Roach | 20 |
| Species | Smelt | 14 |
| Species | Whitefish | 6 |
You can generate additional synthetic data by using the trained tabular GAN model that is saved in the mylib.astore table and PROC ASTORE (see Chapter 4, ASTORE Procedure).
The following statements use PROC ASTORE to generate 100 synthetic data observations by using the trained tabular GAN model that is stored in mylib.astore and then save the results in the mylib.astoreout table:
proc astore;
setoption GENOBS 100;
setoption SEED 42;
score rstore=mylib.astore
out=mylib.astoreout;
run;
The GENOBS option in the SETOPTION statement specifies the number of synthetic observations to generate. To generate different synthetic data, change the SEED option value in the SETOPTION statement.
Note: For tabular GAN analytic stores that are trained on the 2026.02 release or later releases, you can generate a specific number of observations without input data by specifying the GENOBS option when you call PROC ASTORE. However, for tabular GAN analytic stores that are trained on releases earlier than 2026.02, you must provide an input data set that contains the number of rows that corresponds to the number of observations that you want to generate. See the corresponding document version for details.