ERROR 180-322: The story of an error message


First, if you landed on this topic because you encountered this SAS message:

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

...then I'll tell you right now: you've probably left off a semicolon in one of your SAS statements. If you're lucky, the SAS log will show you where it happened by highlighting the offending line with the "180" error number:

proc sql
create table f as select * from sashelp.class;

Punctuation is important in any language. (Recommended reading: Eats, Shoots & Leaves: The Zero Tolerance Approach to Punctuation.) It's especially important in a programming language like SAS, where semicolons are the only way that SAS can determine where one instruction ends and the next one begins.

So why doesn't SAS just say, "Hey buddy -- you're missing a semicolon!" ? The reason is that there are other potential causes for this message. For example, if you drop in a statement that SAS just doesn't understand -- or doesn't understand in the current context -- then the error message "Statement is not valid or it is used out of proper order" pretty much says it all.

But I was curious about the error number: 180-322. Where did that come from? To find out, I had to step into the SAS Wayback Machine.

Error numbers are historical

At SAS, the "Wayback Machine" is personified in Rick Langston, a 35+ year SAS employee who is the main steward of the SAS programming language. I asked Rick about the origin of the error number 180-322, and he immediately logged in to SAS 82.4 to check the behavior.

That's right: He ran SAS 82.4 -- as in, the version of SAS that was available in 1982. He didn't even have to climb into his DeLorean and drive 88MPH. We actually have SAS 82.4 running on a mainframe at SAS. Here's the log from Rick's syntax error test:

1       S A S   L O G    OS SAS 82.4         MVS/XA JOB SAS824   STEP SAS      
NOTE: CPUID   VERSION = 00  SERIAL = 035EA6  MODEL = 2964 .                     
NOTE: SAS OPTIONS SPECIFIED ARE:                                                
1          DATA TEMP; X=1; BLAH;                                                
ERROR:                     180                                                  

While Rick couldn't tell me why the number was set to 180 originally, it's clear why it's there today: legacy. Automated processes depend on error codes, and you can't go changing those error codes after a world of SAS users begin to rely on them. Maybe the "180" is a reference to "180 degrees," as in "turn around and look behind you: you forgot a semicolon!"

The second part of the error code, "322", indicates a grouping of related syntax error messages. Here is a sample of other messages that you'll encounter with the -322 suffix:

75-322 Syntax error, expecting one of the following: <expected keywords>
76-322 Syntax error, statement will be ignored.
77-322 The statement is being ignored.
181-322 Procedure name misspelled.
216-322 No simple repair for the syntax error. The statement is being ignored.

That last one is my favorite but I've never seen it in action. I wonder what sequence of statements would coax the "No simple repair" message into your SAS log? If you can make it happen, let me know in the comments. It sounds like my approach when my family asks me to fix something around the house. "No simple repair -- so IGNORE." (Not recommended, by the way.)

Where to learn more about ERROR and WARNING messages

If you're just getting started with SAS programming, it's a good idea to learn how to interpret the SAS log messages. Here are some papers that help:


About Author

Chris Hemedinger

Director, SAS User Engagement

+Chris Hemedinger is the Director of SAS User Engagement, which includes our SAS Communities and SAS User Groups. Since 1993, Chris has worked for SAS as an author, a software developer, an R&D manager and a consultant. Inexplicably, Chris is still coasting on the limited fame he earned as an author of SAS For Dummies


  1. I learned on 82.4 (and had a hand-me-down 79.5 manual as a reference), but it's spooky to find out there's still a copy running.

    Doesn't make me feel any younger.

    (One day I left work and walked to the parking lot to get my ride, only to discover to my dismay that somebody else's dinosaur had eaten my dinosaur while it was just sitting there in my regular parking space.)

  2. Such a great post - especially to share with the new programmers I teach. Thanks! Does that old mainframe require 1.21 gigawatts?

  3. Peter Lancashire on

    It's interesting to see that the error numbers have a structure. There is some software engineering behind them.
    Other software I have used has come as standard with a comprehensive catalogue of error numbers with explanations and suggestions for how to solve the problem. This was an enormously valuable resource for a beginner.
    Please could you ask your SAS software engineers to share this information with us users? They invented the numbers and the text, so must know what they mean. We need an official place to document (and find) the "well-known" solution to 180-322: look for a missing semi-colon. And all the myriad others.

    • Chris Hemedinger
      Chris Hemedinger on


      Of course it's most helpful when the error message itself is descriptive enough for you to determine the next action. Error messages at SAS go through some review (multiple reviews, actually, since they also need to be localized into many languages). I think that the software has grown to the point that a comprehensive directory of all error messages would be unwieldy. A casual search of Base SAS shows nearly 5000 messages! Thankfully, the most common messages have been described in communities, doc, and SAS Notes.

      • Peter Lancashire on

        The Informix 7.1 book I have from 1994 has over 500 pages with about 5 errors described per page, so roughly 2500. Each has a unique identifier. They also delivered a finderr script to search for them. I imagine software engineering has developed since 1994, so documenting and organizing 5000 explanations should be no problem. Searching for them is difficult (I have tried) because they do not have unique identifiers. Maybe all these online resources have made us lazy?

        • Chris Hemedinger
          Chris Hemedinger on

          I used to work for IBM way back, and I remember working on the tomes that documented all error messages...and wondering, "who's going to read all of these?" Now I know :)

          But all error messages are not equal. There are a handful that people see all of the time, triggered by the most common conditions. And then there are those that cover the very rare events that almost no one will see. I think the common messages are well documented, but the rare messages remain hidden until you hit just the right combination of events to uncover them.

  4. I do not know why I even know/remember this but error 180 used to be a common COBOL error code when something was out of place or when a date/datetime was incorrect... Maybe Data steps did a bit of cobol behind scenes in 70s/80s?

  5. Ods Graphics on/ Attrpriority=none;
    Proc sgplot data=growth;
    Title'Plot of Meanrcd vs family';
    Styleattrs datacontrastcolors=(red blue green orange)
    datasymbols=(Circlefilled trianglefilled squarefilled
    diamondfilled) datalinepatterns= (solid dash shortdash
    series x=repno y=meanrcd/group=family markerattrs=(size=3px)
    I am getting error message that ERROR 180-322: Statement is not valid or it is used out of proper order.for statement styleattrs

    • Chris Hemedinger
      Chris Hemedinger on

      This might depend on your version of SAS. I think STYLEATTRS was added in SAS 9.4 Maint 3.

  6. Hi everyone,

    I am using a macro to change the layout of my dataset. However, I get the following error message:

    180: LINE and COLUMN cannot be determined.
    NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN
    where the error has occurred.
    ERROR 180-322: Statement is not valid or it is used out of proper order.

    /* Here is my code*/
    %Macro layout;
    %do i=1 %to 50;
    Data NewComp&i; Set Comp&i;
    %if _n_=1 %then Comp_Name=B;
    %if _n_=5 %then Code=C;
    Rename A=Shareholder_Id; Label A='Shareholder_Id';
    Rename B=Shareholder_Name; Label B='Shareholder_Name';
    Rename C=Country; Label C='Country';
    Drop I; Drop J;
    %MEND layout;

    Do you any ideas about how this problem can be solved?

    • Chris Hemedinger
      Chris Hemedinger on

      Hi Simou, it looks like there are several problems here -- or maybe you shared an incomplete version of the code.

      • Your macro is not defined to take a parameter, but you provided one in the call -- %layout(Comp).
      • You don't have an I or J variable, but you reference them in DROP statements.
      • You don't need a QUIT statement for this step.

      I think there is more going on in your session, maybe you had an open step or statement that wasn't closed (missing paren or semicolon) from a previous step. You should reset your SAS session and re-run, after addressing the issues I mentioned.

  7. Hi Chris,

    Thank you very much for your reply. I have changed the first line of my code to %Macro layout(sheet). Now it works perfectly without an error message.

    I and J are two variables in the Comp&i files. I wanted to drop them.

    Best regards,


    VALUE AGEFT LOW-<40='20-39'
    VALUE EDUC 0-11='<HS'
    12='HS graduate'
    VALUE EDFT 0-11='<HS'
    12='HS graduate'
    13-15='Some College'
    16='College Grad'
    17-19='Some Graduate';
    VALUE EMPLOYED 0='Unemployed'
    VALUE FULLTIME 2='Full-time'
    VALUE GENDER 1='Male'
    VALUE GENDREV 2='Male'
    VALUE INCOME 0-<20000='<$20K'
    VALUE KIDFT 0='0'
    VALUE MARFT 1-3='Married'
    7='Never Married';
    VALUE MARITAL 1-3='Married'
    7='Never Married';
    VALUE OCCUP 1='Managerial'
    VALUE ORIGIN 17='European'
    VALUE CTRY 1='North America'
    2='South America'
    VALUE NEWCTRY 1='North America'
    2='South America'
    VALUE CTRYFT 1='North America'
    2='South America'
    VALUE CTRY5FT 1='North America'
    2='South America'
    3='Central America'
    VALUE REGION 1='Northwest'
    VALUE RESPFT 1='Prices'
    VALUE SECTOR 1,5,6='Private'
    VALUE UNION 1='Non-Union'
    VALUE DIVFT 1='Northwest'
    value empyrs 0-<1='<1 year'
    1-5='1-5 years'
    5<-10='6-10 years'
    1010 years';

    I am trying to run this code to create a set of format.....and guess what i am having the following message

    2='South America'
    ERROR 180-322: Statement is not valid or it is used out of proper order
    I check every semi colon to see what is wrong and i could not figure out
    please help

    • Chris Hemedinger
      Chris Hemedinger on

      You have an issue at line 30 of this program:


      I found it by adding the code into SAS Enterprise Guide and using the code formatter (Ctl+Shift+B in SAS Enterprise Guide 8.1 and later, or Ctrl+I in earlier releases).

  9. Hi Chris,

    Ive encountered also this Error, but in strange way. Can you explanat the folowing situation?

    In Sas Eg, if you forget a semi colon after quit statement, in SAS Eg the code run succesfully without error 180 322. When i analyse the log in EG i see that Sas Eg adds automatically a semi colon in the log. so the next proc sql just works fine.

    but when the code is exported to. sas file, the code missing a semi colon after the quit statement, what results in the 180-322 error. this is correct, because you forgot a semi colon.

    but why is this not reproducable in sas eg, is there an Automatic option in sas eg thats is Developer friendly why it is adding an semi colon?

    • Chris Hemedinger
      Chris Hemedinger on

      Yes, EG and SAS Studio add a "quote killer" statement to the submission.


      Because an open quote or missing semicolon can leave the client in an odd state, these tools add this to provide a "closure" in the event the original program has a problem.

      • is this standard functionality or is it possible to turn on/off by options?

        Same happening when you use a format that doesnt exists, in Sas eg you do not get an error but if you run the exported sas, it results in ERROR 48-59: The format xxxx was not found or could not be loaded

        • Chris Hemedinger
          Chris Hemedinger on

          I don't think you can turn off the quote killer. And I don't think there is an option to turn off OPTIONS NOFMTERR. But you can add your own code to Tools->Options->SAS Programs, "Submit SAS code when server is connected" and use it to set the standard options you want to enforce.

  10. is this standard functionality or is it possible to turn on/off by options?

    Same happening when you use a format that doesnt exists, in Sas eg you do not get an error but if you run the exported sas, it results in ERROR 48-59: The format xxxx was not found or could not be loaded

Back to Top