VNFERR System Option

Specifies whether SAS issues an error or warning when a BY variable exists in one data set but not another data set when the other data set is _NULL_. This option applies when processing the SET, MERGE, UPDATE, or MODIFY statements.
Valid in: Configuration file, SAS invocation, OPTIONS statement, SAS System Options window
Category: Environment control: Error handling
PROC OPTIONS GROUP= ERRORHANDLING
Note: This option can be restricted by a site administrator. For more information, see Restricted Options.

Syntax

Syntax Description

VNFERR
specifies that SAS issue an error when a BY variable exists in one data set but not in another data set when the other data set is _NULL_. This option applies when processing the SET, MERGE, UPDATE, or MODIFY statements. When the error occurs, SAS enters into syntax-check mode.
NOVNFERR
specifies that SAS issue a warning when a BY variable exists in one data set but not in another data set when the other data set is _NULL_. This option applies when processing the SET, MERGE, UPDATE, or MODIFY statements. When the warning occurs, SAS does not enter into syntax-check mode.

Details

VNF stands for variable not found.
This option is useful when macro variables store data set names and these macro variables are used by the SET, MERGE, UPDATE, or MODIFY statements. If you set NOVNFERR and one of these statements contains a macro variable with a value _NULL_, SAS issues a warning instead of an error and processing continues.
z/OS Specifics: Under z/OS, SAS issues an error or a warning when the data set that is specified by DDNAME points to a DUMMY library.

Comparisons

  • VNFERR is similar to the BYERR system option, which issues an error and enters into syntax-check mode if the SORT procedure attempts to sort a _NULL_ data set.
  • VNFERR is similar to the DSNFERR system option, which issues an error when a SAS data set is not found.

Examples

Example 1

This example shows the results of setting the VNFERR option and the NOVNFERR option:
/* treat variable not found on _NULL_ SAS data set as an error  */

 /* turn option off - should not get an error                    */
 options novnferr; run;
 
 data a;
    x = 1;
    y = 2;
 run;

 data b;
    x = 2;
    y = 3;
 run;

 data _null;
    y = 2; 
 run;

 /*  option is off - should not get an error                     */
data result;
  merge a b  _null_;
   by x;
run;

 /* turn option on - should get an error                         */
 options vnferr; run;

data result2;
  merge a b  _null_;
   by x;
run;
Here is the SAS log:
66   /* treat variable not found on _NULL_ SAS data set as an error  */
67
68    /* turn option off - should not get an error                    */
69    options novnferr; run;
70
71    data a;
72       x = 1;
73       y = 2;
74    run;

NOTE: The data set WORK.A has 1 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds


75
76    data b;
77       x = 2;
78       y = 3;
79    run;

NOTE: The data set WORK.B has 1 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


80
81    data _null;
82       y = 2;
83    run;

NOTE: The data set WORK._NULL has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


84
85    /*  option is off - should not get an error                     */
86   data result;
87     merge a b  _null_;
88      by x;
89   run;

WARNING: BY variable x is not on input data set WORK._null_.
NOTE: There were 1 observations read from the data set WORK.A.
NOTE: There were 1 observations read from the data set WORK.B.
NOTE: The data set WORK.RESULT has 2 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


90
91    /* turn option on - should get an error                         */
92    options vnferr; run;
93
94   data result2;
95     merge a b  _null_;
96      by x;
97   run;

ERROR: BY variable x is not on input data set WORK._null_.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.RESULT2 may be incomplete.  When this step was stopped there were 0 observations and 2
         variables.

Example 2

In this example, the data set, Result, reads from three data sets by using the SET statement. The SET statement values are all macro variables. One of these macro variables, &dataset3, has a value of _NULL_. SAS issues a warning message when it reads &dataset3; and completes the DATA step without an error.
options novnferr;

data a; 
   x = 1; 
   y = 2; 
run;
data b; 
   x = 2; 
   y = 3; 
run;

%let dataset1=a;
%let dataset2=b;
%let dataset3=_null_;

data result;
  set &dataset1 &dataset2 &dataset3;
  by x;
run;
Here is the SAS log:
15   options novnferr;
16
17   data a;
18      x = 1;
19      y = 2;
20   run;

NOTE: The data set WORK.A has 1 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


21   data b;
22      x = 2;
23      y = 3;
24   run;

NOTE: The data set WORK.B has 1 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


25
26   %let dataset1=a;
27   %let dataset2=b;
28   %let dataset3=_null_;
29
30   data result;
31     set &dataset1 &dataset2 &dataset3;
32     by x;
33   run;

WARNING: BY variable x is not on input data set WORK._null_.
NOTE: There were 1 observations read from the data set WORK.A.
NOTE: There were 1 observations read from the data set WORK.B.

See Also

Syntax Check Mode in SAS Language Reference: Concepts