Help using Base SAS procedures

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

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

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

Hello,

 

I am not new to SAS but I am by no means an expert.  I am working with a new dataset and trying to creating some new variables using the "if-then" statement.  However, when I do this, I keep getting the same error with each step.  I can't figure out what I am doing wrong -- I haven't had this problem before using these steps.  Please help! 

 

Here is the code I am using:

 

data=work.allmdsurgeons1;
set=work.allmdsurgeons;
if residency = 0 then res_type = 0;
else res_type= 1;
run;

 

In the log after I run this, under each line I get "ERROR 180-322: Statement is not valid or it is used out of proper order."  I don't know why this is happening for the data step and the set step.  If someone could help I would really appreciate it!  Thanks!

 

Accepted Solutions
Solution
‎02-08-2018 02:15 PM
Super User
Posts: 6,622

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

Your IF/THEN statements are fine.  However, DATA and SET statements don't use an equal sign.  Change the equal sign to a blank character for those two statements.

View solution in original post


All Replies
Solution
‎02-08-2018 02:15 PM
Super User
Posts: 6,622

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

Your IF/THEN statements are fine.  However, DATA and SET statements don't use an equal sign.  Change the equal sign to a blank character for those two statements.

New Contributor
Posts: 2

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

Posted in reply to Astounding

Wow, I feel so stupid. Thanks for the help!

Super User
Posts: 13,283

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

With errors it is usually a good idea to paste the code with error messages. To preserve the formatting of the error messages paste them into a code box opened with the {I} menu icon on in the header of the message box on the forum. Such as:

494  data=work.allmdsurgeons1;
     ----
     180

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

495  set=work.allmdsurgeons;
     ---
     180

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

496  if residency = 0 then res_type = 0;
     --
     180

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

497  else res_type= 1;
     ----
     180

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

498  run;

Which will show us which specific line and where SAS detected the error.

 

Since the first instance is with data you might look at example code (almost anywhere) to remember the data step does not use =, or Set.

The others are because the statements are only valid in a data step and SAS has not recognized the valid start of a data step.

☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 204 views
  • 0 likes
  • 3 in conversation