DATA Step, Macro, Functions and more

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

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 7
Accepted Solution

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

[ Edited ]

I got the error message below surprisingly. I don't understand why it says statement is not valid. This proc sql is imbedded in a macro and if I run it individually, it is working. I even tried to use data step in replace of proc sql but it still says "statement is not valid". Hope some one can help me out. TX! 

 

13          proc sql; create table normssp as select * from tmp where nss_norm = "&asso" and spx_test_name = "&sub" and
                      ------
                      180
13  ! nss_grade = "&grad"; quit;  
ERROR 180-322: Statement is not valid or it is used out of proper order.

 


Accepted Solutions
Solution
‎08-26-2016 08:18 AM
Community Manager
Posts: 2,768

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

[ Edited ]

Thanks to @Tom@SASKiwi, and @dkb for excellent advice -- all deserve credit for solving this.  I'm going to close this out by summarizing:

  • ERROR 180-322 ... is most often caused by a missing semicolon in the program that you submitted.  In this case, perhaps your proc sql line was interpreted as part of a previous comment line, so the create table statement was "out of order".

  • Code generated by a SAS macro, or submitted with a "submit selected" operation in your editor, can leave off a semicolon inadvertently -- that's not always easy to find.  So examine not just the code that you see in your program editor, but consider what was actually submitted to SAS when the error was produced.

  • For more some fun information about this common syntax error message, see this blog post: ERROR 180-322: The story of an error message

View solution in original post


All Replies
Super User
Posts: 3,113

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

I think you have answered your own question as you say it doesn't work inside your macro.

You need to post your complete program with the surrounding macro code before we can help you.

Super User
Super User
Posts: 6,502

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

You are missing a semi-colon somewhere before the PROC SQL; statement.  So the CREATE STATEMENT is invalid since you did not start PROC SQL first.

Contributor dkb
Contributor
Posts: 53

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

Well caught, Tom.

Viewing the snippet of the log in a monospace font makes it easier to understand where the error is.

Occasional Contributor
Posts: 7

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

Thank you. But I didn't find any semi-colons missing. Anyways, it worked when I removed my comments line before this proc sql.

Contributor dkb
Contributor
Posts: 53

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

Sounds as though your missing semi-colon was on the comment line.  Remember if you begin a line with an asterisk, not only is that line a comment, so is everything between the asterisk and the next semi-colon that SAS finds, even if it's several lines later.

Occasional Learner
Posts: 1

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

My code also had the same issue. It worked when I removed comments after reading this. Thanks
Solution
‎08-26-2016 08:18 AM
Community Manager
Posts: 2,768

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

[ Edited ]

Thanks to @Tom@SASKiwi, and @dkb for excellent advice -- all deserve credit for solving this.  I'm going to close this out by summarizing:

  • ERROR 180-322 ... is most often caused by a missing semicolon in the program that you submitted.  In this case, perhaps your proc sql line was interpreted as part of a previous comment line, so the create table statement was "out of order".

  • Code generated by a SAS macro, or submitted with a "submit selected" operation in your editor, can leave off a semicolon inadvertently -- that's not always easy to find.  So examine not just the code that you see in your program editor, but consider what was actually submitted to SAS when the error was produced.

  • For more some fun information about this common syntax error message, see this blog post: ERROR 180-322: The story of an error message
New User
Posts: 1

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

Thanks , this solves my issue too Smiley Happy

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 26258 views
  • 6 likes
  • 7 in conversation