BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Xiuchen
Fluorite | Level 6

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.

 

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

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
It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.

View solution in original post

8 REPLIES 8
SASKiwi
PROC Star

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.

Tom
Super User Tom
Super User

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.

dkb
Quartz | Level 8 dkb
Quartz | Level 8

Well caught, Tom.

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

Xiuchen
Fluorite | Level 6

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

dkb
Quartz | Level 8 dkb
Quartz | Level 8

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.

arunnethi123
Calcite | Level 5
My code also had the same issue. It worked when I removed comments after reading this. Thanks
ChrisHemedinger
Community Manager

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
It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Sandipana
Calcite | Level 5

Thanks , this solves my issue too 🙂

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 181555 views
  • 8 likes
  • 7 in conversation