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.
Thanks to @Tom, @SASKiwi, and @dkb for excellent advice -- all deserve credit for solving this. I'm going to close this out by summarizing:
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.
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.
Well caught, Tom.
Viewing the snippet of the log in a monospace font makes it easier to understand where the error is.
Thank you. But I didn't find any semi-colons missing. Anyways, it worked when I removed my comments line before this proc sql.
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.
Thanks to @Tom, @SASKiwi, and @dkb for excellent advice -- all deserve credit for solving this. I'm going to close this out by summarizing:
Thanks , this solves my issue too 🙂
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.