As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.


Here are some tips for How to share your SAS knowledge with your professional network.


Difference between revisions of "Errors"

From sasCommunity
Jump to: navigation, search
(ERROR 22-322: Syntax error: another case...)
 
(11 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
This page documents some common errors in [[SAS]], and provides some pointers for resolution.
 +
 
== Cannot Start SAS ==
 
== Cannot Start SAS ==
  
Line 33: Line 35:
 
Solution.2: when running from a network drive such as Citrix,
 
Solution.2: when running from a network drive such as Citrix,
 
make sure the '''My Computer''' has the correct setting:
 
make sure the '''My Computer''' has the correct setting:
 
  
 
<pre>
 
<pre>
Line 40: Line 41:
  
 
== Macro statements ==
 
== Macro statements ==
 
+
===Omitting a Semicolon===
Missing semicolon at end of assignment statement
+
Missing the [[semicolon]] at end of assignment statement
  
 
<pre>
 
<pre>
Line 48: Line 49:
 
ERROR: Open code statement recursion detected.
 
ERROR: Open code statement recursion detected.
 
</pre>
 
</pre>
 +
 +
===Undefined macro variable===
 +
If you haven't previously declared, defined or assigned a value to a macro variable before you use it you can get a '''warning''' message about an ''Apparent symbolic reference'' to the variable concerned being ''not resolved.'' This can also happen if a macro variable is deleted. Such warnings can indicate typographical or logic errors in your code.
 +
 +
<source lang="sas">
 +
23        %let d = b ;
 +
24        %put &=b;
 +
WARNING: Apparent symbolic reference B not resolved.
 +
b
 +
25       
 +
</source>
 +
In this example the line at 24 should be ''%put &='''d''';''
  
 
== SQL ==
 
== SQL ==
  
search SAS-L archives for:  
+
search [[SAS-L]] archives for:  
  
 
subject: PROC SQL ERROR 65-58: Name too long
 
subject: PROC SQL ERROR 65-58: Name too long
  
 +
== ERROR 22-322: Syntax error ==
 +
This error may be followed by "<span style="color:#FF0000;">expecting one of the following: a name, a quoted string, ...</span>" or "<span style="color:#FF0000;">expecting one of the following: a name, *.</span>"
 +
 +
One of the possible causes of this error is the use of a [[macro variable]] (<big><source lang="sas" enclose="none">&some_variable_name.</source></big>) that has not been initialized. This may happen if you copy the code from another source, or if you run a section of code not including the initialization of said macro variable.
 +
 +
This error can also be thrown if a line does not terminate in a semicolon, an unexpected word or identifier is used or there are unmatched parentheses or quotes in the statement.
 +
 +
Another cause is if you use multiple ''aliases'' by mistake. If your SELECT statement in a [[query]] contains two aliases (like a.b.columnName), perhaps because the code was copied from somewhere else and a second alias was inserted, this error will be thrown.
 +
 +
== ERROR 180-322: Statement is not valid or it is used out of proper order. ==
 +
[http://blogs.sas.com/content/sasdummy/2016/08/25/error-180-322-missing-semicolon/ This SAS blog post] tells the interesting story of this common error message that often means "you forgot a semicolon!"
 +
 +
This error may also be encountered if you end a [[DATA step]] with a <span style="color:#191970;">'''quit'''</span>''';''' statement rather than a <span style="color:#191970;">'''run'''</span>''';''' statement.
 +
 +
== The variable X is uninitialized ==
 +
If you get this error message in a DATA step, you may have forgotten the SET statement.
 +
 +
For more on this and other errors, see [[Explaining Unexpected Log Messages and Output Results from DATA Step Code]].
 +
 +
== See also ==
 +
* [[Errors, Warnings, and Notes (Oh My): A Practical Guide to Debugging SAS® Programs]]
  
--macro maven == the radical programmer 11:28, 8 November 2008 (EST)
 
 
[[Category: Best Practices]]
 
[[Category: Best Practices]]
 
[[Category: Guides]]
 
[[Category: Guides]]

Latest revision as of 12:58, 20 September 2017

This page documents some common errors in SAS, and provides some pointers for resolution.

Cannot Start SAS

ERROR: Invalid physical name for library SASUSER.
FATAL: Unable to initialize the options subsystem.
ERROR:   (SASXKINI): PHASE 3 KERNEL INITIALIZATION FAILED.
UNABLE TO INITIALIZE THE SAS KERNEL

Cause: invalid argument to option SASuser in Primary Configuration File:

  •  !SASroot\nls\en\SASv9.cfg
/* name: Primary Configuration file for SAS v9.1.3 or SAS v9.2 */
/* Setup the default SAS System user profile folder */
-SASUSER "?CSIDL_PERSONAL\My SAS Files\9.1"

/* Setup the MYSASFILES system variable             */
-SET MYSASFILES "?CSIDL_PERSONAL\My SAS Files\9.1"

Solution.1: add these lines to your Secondary config file:

/* name: Secondary Config File !SASroot\SASv9.cfg */
/* [snip] */

-SASUSER        'C:\temp\My SAS Files\9.2\'
-SET MYSASFILES 'C:\temp\My SAS Files\9.2\' /* *** */

Solution.2: when running from a network drive such as Citrix, make sure the My Computer has the correct setting:


Macro statements

Omitting a Semicolon

Missing the semicolon at end of assignment statement

1  %Let Test1 = missing semicolon
2  %Let Test2 = has semicolon;
ERROR: Open code statement recursion detected.

Undefined macro variable

If you haven't previously declared, defined or assigned a value to a macro variable before you use it you can get a warning message about an Apparent symbolic reference to the variable concerned being not resolved. This can also happen if a macro variable is deleted. Such warnings can indicate typographical or logic errors in your code.

23         %let d = b ;
24         %put &=b;
WARNING: Apparent symbolic reference B not resolved.
b
25

In this example the line at 24 should be %put &=d;

SQL

search SAS-L archives for:

subject: PROC SQL ERROR 65-58: Name too long

ERROR 22-322: Syntax error

This error may be followed by "expecting one of the following: a name, a quoted string, ..." or "expecting one of the following: a name, *."

One of the possible causes of this error is the use of a macro variable (&some_variable_name.) that has not been initialized. This may happen if you copy the code from another source, or if you run a section of code not including the initialization of said macro variable.

This error can also be thrown if a line does not terminate in a semicolon, an unexpected word or identifier is used or there are unmatched parentheses or quotes in the statement.

Another cause is if you use multiple aliases by mistake. If your SELECT statement in a query contains two aliases (like a.b.columnName), perhaps because the code was copied from somewhere else and a second alias was inserted, this error will be thrown.

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

This SAS blog post tells the interesting story of this common error message that often means "you forgot a semicolon!"

This error may also be encountered if you end a DATA step with a quit; statement rather than a run; statement.

The variable X is uninitialized

If you get this error message in a DATA step, you may have forgotten the SET statement.

For more on this and other errors, see Explaining Unexpected Log Messages and Output Results from DATA Step Code.

See also