Possible error messages when using the words _NEW_ or NOT in expressions


As of SAS 9.0, _NEW_ is a prefix OPERATOR. When _NEW_ is used in an expression, the compiler thinks it is an OPERATOR and expects the token after _NEW_ to be a component name, as in "_NEW_ HASH()". The following ERROR messages might appear in the log:

ERROR 388-185: Expecting an arithmetic operator.

ERROR 76-322: Syntax error, statement will be ignored.

To avoid the ERROR messages, you can rename the variable or use name literal syntax ('_NEW_'n) when using the variable in an expression.

The following sample illustrates the issue:

/* The IF condition doesn't work because _NEW_ is */ 

/* seen as a prefix operator, not a variable name. */

data _null_;

_new_ = 1;

if _new_ = 1 then put _all_;

run;

/* Quoting the variable _NEW_ with the name literal syntax */

/* corrects the issue. */

data _null_;

_new_ = 1;

if '_new_'n = 1 then put _all_;

run;

NOT is another example of a prefix OPERATOR that can cause the following syntax error messages:

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant, a missing value, INPUT, PUT.

ERROR 180-322: Statement is not valid or it is used out of proper order.

The following sample illustrates the issue:

/* NOT is a prefix operator and will cause an error */

/* when used in an IF condition if not quoted. */

data _null_;

NOT = 1;

if NOT = 1 then put _all_;

run;

/* Quoting the variable NOT with the name literal syntax */

/* corrects the issue. */

data _null_;

NOT = 1;

if 'NOT'n = 1 then put _all_;

run;