ERROR 180-322: The story of an error message

23

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;
______
180

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: THE JOB SAS824 HAS BEEN RUN UNDER RELEASE 82.4 OF SAS AT SAS INSTITUTE DEV
NOTE: CPUID   VERSION = 00  SERIAL = 035EA6  MODEL = 2964 .                     
NOTE: SAS OPTIONS SPECIFIED ARE:                                                
       SORT=4                                                                   
1          DATA TEMP; X=1; BLAH;                                                
                           ____                                                 
ERROR:                     180                                                  
180:  STATEMENT IS NOT VALID OR IT IS USED OUT OF PROPER ORDER.                 

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:

Share

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

23 Comments

  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

      Peter,

      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
    shortdashdot);
    series x=repno y=meanrcd/group=family markerattrs=(size=3px)
    lineattrs=(thickness=7px);
    run;
    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;
    Run;
    quit;
    %end;
    %MEND layout;
    %layout(Comp);

    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,

    Simou

  8. PROC FORMAT;
    VALUE AGEFT LOW-<40='20-39'
    40-<60='40-59'
    60-HIGH='60+';
    VALUE EDUC 0-11='<HS'
    12='HS graduate'
    13-19='College';
    VALUE EDFT 0-11='<HS'
    12='HS graduate'
    13-15='Some College'
    16='College Grad'
    17-19='Some Graduate';
    VALUE EMPLOYED 0='Unemployed'
    1='Employed';
    VALUE FULLTIME 2='Full-time'
    3,4,5='Part-time';
    VALUE GENDER 1='Male'
    2='Female';
    VALUE GENDERFT 1='Male'
    2='Female';
    VALUE GENDREV 2='Male'
    1='Female';
    VALUE GRADEFT 4='A'
    3='B'
    2='C'
    1='D'
    0='F';
    VALUE INCOME 0-<20000='<$20K'
    20000-50000='$20K-$50K'
    50000$50K';
    VALUE KIDFT 0='0'
    1='1'
    2-HIGH='2+';
    VALUE MARFT 1-3='Married'
    4-6='Widow/Div/Sep'
    7='Never Married';
    VALUE MARITAL 1-3='Married'
    4='Widowed'
    5-6='Divorced/Sep.'
    7='Never Married';
    VALUE OCCUP 1='Managerial'
    2='Professional'
    3='Technical'
    4='Sales'
    5='Clerical'
    6-8='Services'
    9-10='Manufacturing'
    11-12='Transport'
    13-14='Farming';
    VALUE ORIGIN 17='European'
    88='Non-European';
    VALUE CTRY 1='North America'
    2='South America'
    3='Other';
    VALUE NEWCTRY 1='North America'
    2='South America'
    3-5='Other';
    VALUE CTRYFT 1='North America'
    2='South America'
    3-5='Other';
    VALUE CTRY5FT 1='North America'
    2='South America'
    3='Central America'
    4='Europe'
    5='Asia';
    VALUE REGION 1='Northwest'
    2='Northeast'
    3='Southwest'
    4='Southeast';
    VALUE RESPFT 1='Prices'
    2='Service'
    3='Location'
    4='Hours'
    5='Variety';
    VALUE SECTOR 1,5,6='Private'
    2,3,4='Public';
    VALUE UNION 1='Non-Union'
    2='Union';
    VALUE YESNOFT 0='No'
    1='Yes';
    VALUE DIVFT 1='Northwest'
    2='Northeast'
    3='Southwest'
    4='Southeast';
    value empyrs 0-<1='<1 year'
    1-5='1-5 years'
    5<-10='6-10 years'
    1010 years';
    RUN;

    PS
    Hello
    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'
    _
    180
    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:

      50000$50K';
      

      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.

      ;*';*";*/;quit;run;
      

      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