8.2 - Invalid Options, Names, or Statements

This section illustrates the kinds of messages you might see in the log window when you've used an invalid option, invalid name, or invalid statement.

Example 8.4 Section

The following example illustrates the "Error: Invalid option" message SAS displays in the log window when you attempt to use an option that is invalid:

DATA trees (ROP = crown_ft);
    input type $ 1-16 circ_in hght_ft crown_ft;
	DATALINES;
oak, black        222 105 112
hemlock, eastern  149 138  52
ash, white        258  80  70
cherry, black     187  91  75
maple, red        210  99  74
elm, american     229 127 104
;
RUN;

   DATA trees (ROP = crown_ft);
               ---
               22
ERROR 22-7: Invalid option name ROP.

     input type $ 1-16 circ_in hght_ft crown_ft;
     DATALINES;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
    real time           0.01 seconds
    cpu time            0.03 seconds

   ;

   RUN;

We'll learn down the road that we can use the DATA statement's DROP= option when we want SAS to drop a variable from the program data vector before writing observations to the output data set. In the above program, we attempt to drop the variable crown_ft from the output trees data set. As you can see, though, we forgot to type the starting D. SAS doesn't know that though ... it thinks we want to use the nonexistent ROP= option. Launch and run  the SAS program, and review the log window to see the message SAS displays in this situation.

Example 8.5 Section

The following example illustrates the "Error: Syntax error" message SAS displays in the log window when your input statement is incorrect:

DATA trees;
    input *type $ 1-16 circ_in hght_ft crown_ft;
	DATALINES;
oak, black        222 105 112
hemlock, eastern  149 138  52
ash, white        258  80  70
cherry, black     187  91  75
maple, red        210  99  74
elm, american     229 127 104
;
RUN;

   DATA trees;
       input *type $ 1-16 circ_in hght_ft crown_ft;
             -
             22
             200
ERROR 22-322: Syntax error, expecting one of the following: a name, arrayname, #, (, +, /, //, ;, @, @@.

ERROR 200-322: The symbol is not recognized and will be ignored.

       DATALINES;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.TREES may be incomplete.  When this step was stopped there were 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
    real time           0.02 seconds
    cpu time            0.01 seconds

   ;

   RUN;

Of course, what is really going on here is that we are trying to use an invalid variable name. Recall that variable names must begin with a letter or an underscore. Trying to specify a variable name *type thus causes SAS to hiccup. SAS does not recognize *type as a valid variable name and therefore provides a list of items SAS would expect to follow the INPUT keyword. Launch and run  the SAS program, and review the log window to see the message SAS displays in this situation.

Example 8.6 Section

The following example illustrates the "Error: Statement is not valid or it is used out of proper order" message SAS displays in the log window when you attempt to use a statement that is not valid:

DATA trees;
    input type $ 1-16 circ_in hght_ft crown_ft;
	DATALINES;
oak, black        222 105 112
hemlock, eastern  149 138  52
ash, white        258  80  70
cherry, black     187  91  75
maple, red        210  99  74
elm, american     229 127 104
;
RUN;
PROC PRINT;
     set type circ_in hght_ft;
RUN;

   DATA trees;
       input type $ 1-16 circ_in hght_ft crown_ft;
       DATALINES;

NOTE: The data set WORK.TREES has 6 observations and 4 variables.
NOTE: DATA statement used (Total process time):
    real time           0.01 seconds
    cpu time            0.01 seconds

   ;
   RUN;

   PROC PRINT;
NOTE: Writing HTML Body file: sashtml.htm
        set type circ_in hght_ft;
        ---
        180
ERROR 180-322: Statement is not valid or it is used out of proper order.
   RUN;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE PRINT used (Total process time):
    real time           0.51 seconds
    cpu time            0.32 seconds

Of course, instead of using the SET statement to tell SAS what variables we would like displayed, we should be using the VAR statement. Launch and run  the SAS program, and review the log window to see the message SAS displays in this situation.

Whether your program contains an invalid option, invalid name, or invalid statement, simply use the log messages to locate the problem and make the appropriate correction to your program. After you resubmit your corrected program, check the SAS log again to make sure there are no other errors.