hey, I'm confused what's the problem with these codes.
Log shows ERROR 180-322: Statement is not valid or it is used out of proper order.
Is there anything wrong?😰
%let T = "Temp_status";
%let W = "Work_Status";
%let C = "cough";
Data Grocery2;
set Grocery1;
if &T = "missing" or &C = "" then &W = "DayOff" ;
else if &T = "normal" and &C = "N" then &W = "Worked" ;
else &W = "Sick" ;
run ;
proc freq data = grocery2;
table &T*&C*&W/list missing ;
run ;
Please copy the entire data step or procedure when asking questions about notes, errors or warnings. Sometimes the "cause" is something before the place indicates an error such as a missing semicolon, matching quote or parentheses.
Copy the entire text from the LOG, open a text box on the forum using the </> icon and paste the text.
Many of the errors like 180-322 often place diagnostic characters in the text and pasting the result into the main message window gets the text reformatted so the diagnostics are in the wrong place.
Your use of &W is placing it in the position of a variable assigning a value. By default variable names cannot contain quote marks.
If &T and &C are also supposed to be variables do not place the value in quotes.
You have created lines of code like:
Data Grocery2; set Grocery1; if "Temp_status"= "missing" or "cough" = "" then "Work_status" = "DayOff" ; else if "Temp_status" = "normal" and "cough" = "N" then "Work_status" = "Worked" ; else "Work_status" = "Sick" ; run ;
Since this code compares the literal text value of "Temp_status" to "missing" or "normal" it is never true. Also "cough" is never true compared to "" or "N".
Please copy the entire data step or procedure when asking questions about notes, errors or warnings. Sometimes the "cause" is something before the place indicates an error such as a missing semicolon, matching quote or parentheses.
Copy the entire text from the LOG, open a text box on the forum using the </> icon and paste the text.
Many of the errors like 180-322 often place diagnostic characters in the text and pasting the result into the main message window gets the text reformatted so the diagnostics are in the wrong place.
Your use of &W is placing it in the position of a variable assigning a value. By default variable names cannot contain quote marks.
If &T and &C are also supposed to be variables do not place the value in quotes.
You have created lines of code like:
Data Grocery2; set Grocery1; if "Temp_status"= "missing" or "cough" = "" then "Work_status" = "DayOff" ; else if "Temp_status" = "normal" and "cough" = "N" then "Work_status" = "Worked" ; else "Work_status" = "Sick" ; run ;
Since this code compares the literal text value of "Temp_status" to "missing" or "normal" it is never true. Also "cough" is never true compared to "" or "N".
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.