DATA Step, Macro, Functions and more

Error 180-322 Statement not valid or used out of proper order

Reply
New Contributor
Posts: 2

Error 180-322 Statement not valid or used out of proper order

Hi,

 

I am brand new to SAS and am learning from the book Learning SAS from example. Problem 5.3, there are answers, and I have copied them, with the only difference that I am using the SAS University Edition on Vbox, a UNIX based system, not windows. I am extremely frustrated because I am getting the 180-322 error after the datalines and everthing seems just fine to me, after lots and lots of looking at it. Maybe someone can let me know what the problem is? Thanks!

Below is the code:

--------------------------------

 

Libname Myfold '/folders/myfolders/sasuser.v94/Perm/MyFold' ; 

Data myfold.colors ;
input Color : $1. @@ ;
datalines ;
R R B G Y Y . . B G R B G Y P O O V V B ;


proc format ;
value $color 'R' , 'B' , 'G' = 'Group1'
'Y' , 'O' = 'Group2'
' ' = 'Not Given'
Other = 'Group3' ;
run ;

Title "Colors Frequencies (Grouped)" ;
proc freq data=myfold.colors ;
Tables Color / nocum missing ;
format color $color. ;
run ;

 

PROC Star
Posts: 162

Re: Error 180-322 Statement not valid or used out of proper order

[ Edited ]


Data colors ;
input Color : $1. @@ ;
datalines ;
R R B G Y Y . . B G R B G Y P O O V V B
;/*notice here*/

 

what's the problem

PROC Star
Posts: 162

Re: Error 180-322 Statement not valid or used out of proper order

Oh right, just the placement of the ; should have been after the last dataline in the next line

New Contributor
Posts: 2

Re: Error 180-322 Statement not valid or used out of proper order

Great! Thanks. I didn;t know the semicolon HAD to be on the next line. I thought that was optional.

PROC Star
Posts: 162

Re: Error 180-322 Statement not valid or used out of proper order

You are welcome. ; is basically known as a null statement. It's very interesting statement and has some relevance as it is an executable statement. In some instances, you can even use that for conditional processing however that is out of scope for this thread. Have fun!
Contributor
Posts: 72

Re: Error 180-322 Statement not valid or used out of proper order

@ManitobaMoose I think it's pretty simple. Mark the question as answered.

Super User
Posts: 6,928

Re: Error 180-322 Statement not valid or used out of proper order


ManitobaMoose wrote:

Great! Thanks. I didn;t know the semicolon HAD to be on the next line. I thought that was optional.


When using datalines; or cards;, a single semicolon in a line will be recognized as the end of the datalines section (and, by defintion, the end of the data step). If something else comes before that semicolon in that line, it is treated as the first statement fo the next step. Since your line does not contain valid SAS code, it causes the error.

If you need to have semicolons in your datalines, use the datalines4; statement. Then 4 successive semicolons are needed to end the datalines section.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 6 replies
  • 82 views
  • 4 likes
  • 4 in conversation