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

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 ;

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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".

 

 

 

View solution in original post

1 REPLY 1
ballardw
Super User

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".

 

 

 

sas-innovate-2024.png

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.

 

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
  • 1 reply
  • 415 views
  • 1 like
  • 2 in conversation