NNET Procedure

Getting Started: NNET Procedure

Note: Input data must be in a table that is accessible in your session. You can refer to this table by using a two-level name. The first level is a libref, and the second level is the table name. For more information, see the section Using SAS Viya Workbench in Chapter 2, Shared Concepts.

This example shows how to use the NNET procedure to train a neural network to predict the type of iris plant. The iris data published by Fisher (1936) have been widely used for examples in discriminant and cluster analyses. The sepal length, sepal width, petal length, and petal width are measured in millimeters on 50 iris specimens from each of three species: Iris setosa, I. versicolor, and I. virginica. The data set is available in the Sashelp library.

You can load the sashelp.iris data into your SAS library by naming your SAS library in the first statement of the following DATA step:

data mylib.iris;
   set sashelp.iris;
run;

These statements assume that your SAS library is named mylib, but you can substitute any appropriately defined SAS library.

The following statements run PROC NNET and output the results to ODS tables:

proc nnet data=mylib.iris;
   input SepalLength SepalWidth PetalLength PetalWidth;
   target Species / level=nominal;
   hidden 2;
   train outmodel=mylib.nnetModel_gs seed=635117188;
   partition fraction(validate=0.3 seed=103873735);
run;

Figure 1 shows the model information for the neural network.

Figure 1: Model Information

The NNET Procedure

Model Information
ModelNeural Net
Number of Observations Used93
Number of Observations Read93
Target/Response VariableSpecies
Number of Nodes9
Number of Input Nodes4
Number of Output Nodes3
Number of Hidden Nodes2
Number of Hidden Layers1
Number of Weight Parameters14
Number of Bias Parameters5
ArchitectureMLP
Seed for Initial Weight635117188
Optimization TechniqueLBFGS
Number of Neural Nets1
Objective Value0.2194992373
Misclassification Rate for Validation0


Figure 2 shows the misclassification rate for the training sample.

Figure 2: Score Information for Training Data

Score Information for Training
Number of Observations Read93
Number of Observations Used93
Misclassification Rate0.0215


Figure 3 shows the misclassification rate for the validation sample.

Figure 3: Score Information for Validation Data

Score Information for Validation
Number of Observations Read57
Number of Observations Used57
Misclassification Rate0


Last updated: September 23, 2026