8.2 - Invalid Options, Names, or Statements

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

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;

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

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;

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

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;

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.


Legend
[1]Link
Has Tooltip/Popover
 Toggleable Visibility