Error 180 322 statement is not valid or it is used out of proper order

The error "error 180-322: statement is not valid or it is used out of proper order" typically occurs when you are using the SAS programming language and you have written a statement that is not syntactically correct, or that is being used in a context where it is not allowed. To fix this error, you will need to carefully review your code and make sure that all statements are written correctly and are being used in the proper order. Here are a few common causes of the "error 180-322" error and h

The error «error 180-322: statement is not valid or it is used out of proper order» typically occurs when you are using the SAS programming language and you have written a statement that is not syntactically correct, or that is being used in a context where it is not allowed.

To fix this error, you will need to carefully review your code and make sure that all statements are written correctly and are being used in the proper order. Here are a few common causes of the «error 180-322» error and how to fix them:

You have written a statement that is not valid in SAS.

To fix this, you will need to make sure that you are using valid SAS syntax. You can refer to the SAS documentation or a SAS reference guide to see a list of valid SAS statements and how they should be used.

You have used a statement in a context where it is not allowed.

For example, you may have used a DATA step statement in a PROC step, or you may have used a PROC step statement outside of a PROC step. To fix this, you will need to make sure that you are using statements in the proper context.

You have used a statement out of order.

For example, you may have used a PROC step statement before a DATA step statement, or you may have used a RUN statement before a PROC step statement. To fix this, you

SAS (Statistical Analysis System) is a software suite for data management and statistical analysis. It is widely used by businesses, organizations, and researchers to analyze and interpret large and complex datasets.

Some common questions about SAS programming include:

  1. What can I do with SAS?

SAS is a powerful tool for a wide range of tasks, including data manipulation, statistical analysis, data visualization, and more. It is particularly useful for tasks that involve working with large and complex datasets, as it has a range of functions and procedures for efficiently analyzing and interpreting data.

  1. How do I get started with SAS?

To get started with SAS, you will need to install the SAS software on your computer. You can download the latest version of SAS from the SAS website (https://www.sas.com/). Once you have installed SAS, you can start using the SAS programming language to write and run SAS programs.

  1. How do I learn SAS?

There are many resources available to help you learn SAS, including online tutorials, textbooks, and courses. Some popular resources include the SAS documentation (https://documentation.sas.com/), the SAS programming course on Coursera (https://www.coursera.org/courses?query=sas+programming), and the SAS programming course on LinkedIn Learning (https://www.linkedin.com/learning/sas-programming).

  1. What are some good SAS procedures to use?

There are many useful SAS procedures available for a wide range of tasks, including data manipulation, statistical analysis, and data visualization. Some popular procedures include PROC PRINT

Related to Links about the error and Sas Programming

Same error with different solution on sas.com

180-322 Sas Error on Stackoverflow

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:

  • What’s That Note/Warning/Error Mean and How Do I Fix It? by Deb Cassidy
  • The top 10 errors, notes and warnings that prompt DATA step programmers to call SAS Technical Support, by Kim Wilson
  • SAS Macro Errors: the Answers You’re Looking For, by Russ Tyndall
  • Deja-vu All Over Again: Common Mistakes by New SAS Users, by Bruce Gilsen

The post ERROR 180-322: The story of an error message appeared first on The SAS Dummy.

When a SAS program is executed, SAS generates a log. The log echoes program statements,
provides information about computer resources and provides diagnostic
information. 

Understanding the log enables you to identify and
correct errors in your program. The log contains three types of messages: Notes,
Warnings and Errors. Although notes and warnings will not cause the program
to terminate, they are worthy of your attention, since they may alert you to potential
problems. An error message is more serious, since it indicates
that the program has failed and stopped execution.

Most of the errors can be easily corrected and this page discusses how some common
errors occur and how to correct them.

Strategies in finding and correcting errors

1. Start at the beginning
Do not become alarmed if your program has several errors in it. Sometimes there is a
single error in the beginning of the program that causes the others. Correcting this error
may eliminate all those that follow. Start at the beginning of your program and work down.

2. Debug your programs one step at a time
SAS executes programs in steps, so even if you have an error in a step written in the
beginning of your program, SAS will try to execute all subsequent steps, which wastes not
only your time, but computer resources as well. Simplify your work. Correct your programs
one step at a time, before proceeding to the next step. As mentioned above, often a single
error in the beginning of the program can create a cascading error effect. Correcting an
error in a previous step may eliminate other errors.

Look at the statements immediately above and immediately
following the line with the error. SAS will underline the error where it detects it,
but sometimes the actual error is in a different place in your program, typically the
preceding line.

3. Look for common errors first
Most errors are caused by a few very common mistakes.

Common errors

1. Missing semicolon

This is by far the most common error. A missing semicolon will cause SAS to misinterpret
not only the statement where the semicolon is missing, but possibly several statements
that follow. Consider the following program, which is correct, except for the missing
semicolon:

 
proc print data =  auto
    var make mpg;
run;
 

The missing semicolon causes SAS to
read the two statements as a single statement. As a result, the var
statement is read as an option to the procedure. Since there is no var option in
proc
print
, the program fails.

 
      proc print data = auto
44        var make mpg;
          ------------
          202 202  202
45        run;

ERROR 202-322: The option or parameter is not recognized.
NOTE: The SAS System stopped processing this step because of errors.
 

The syntax for the following program is absolutely
correct, except for the missing semicolon on the comment:

 
* Build a file named auto2

data auto2;
      set auto;
     ratio=mpg/weight;
run;


34   * Build a file named auto2
35
36     data auto2;
37       set auto;
         -------
         180
ERROR 180-322: Statement is not valid or it is used out of proper order.
38       ratio=mpg/weight;
         ------- 
         180
ERROR 180-322: Statement is not valid or it is used out of proper order.
39     run;
 

Taken out of the context of the
program, both statements are correct.

 set auto;
  ratio=mpg/weight;
 

However, SAS flags them as errors
because it fails to read the data statement correctly. Instead, it reads this
statement as part of the comment.

 * Build a file named auto2      data auto2; 

Why? Because the first semicolon it encounters is
after the word auto2. Consequently the two correct statements are now errors.

2. Misspellings

Sometimes SAS will correct your spelling mistakes for
you by making its best guess at what you meant to do. When this happens, SAS will continue
execution and issue a warning explaining the assumption it has made. Consider for
example, the following program:

DAT auto ;
  INPUT make $  mpg rep78 weight foreign ;
CARDS;
AMC     22 3 2930 0
AMC     17 3 3350 0
AMC     22 . 2640 0
;
run;

Note that the word «DATA» is misspelled. If we
were to run this program, SAS would correct the spelling and run the program but issue a
warning.

68   DAT auto ;
     ----
14 69 INPUT make $ mpg rep78 weight foreign ; 
   70 CARDS; WARNING 14-169: Assuming the symbol DATA was misspelled as DAT. 
NOTE: The data set WORK.AUTO has 26 observations and 5 variables. 

Sometimes SAS identifies a spelling error in a note,
which does not cause the program to fail. Never assume that a program that has run without
errors is correct! Always review the SAS log for notes and warning as well as errors.

The following program runs successfully, but is it
correct?

data auto2;
  set auto;
  ratio = mpg/wieght;
run;

A careful review of the SAS log reveals that it is not.

75   data auto2;
76      set auto;
77      ratio = mpg/wieght;
78   run;

NOTE: Variable WIEGHT is uninitialized.
NOTE: Missing values were generated as a result of performing an
      operation on missing values.
      Each place is given by:
      (Number of times) at (Line):(Column). 	6 at 77:15
NOTE: The data set WORK.AUTO2 has 26 observations and 7 variables.

Sometimes missing values are legitimate. However, when a
variable is missing for every record in the file, there may be a problem with the
program, as illustrated above. More often, when your program contains spelling errors, the
step will terminate and SAS will issue an error statement or a note underlining the word,
or words, it does not recognize.

65   proc print
66   var make mpg weight;
     ----
     76
67   run;

ERROR 76-322: Syntax error, statement will be ignored.
NOTE: The SAS System stopped processing this step because of errors.

In this example, there is nothing wrong with the var statement.
Adding a semicolon to the proc print solves the
problem.

proc print; 
   var make mpg weight;
run;

The following code will successfully create a new dataset auto2.

data auto2; 
  set uato; 
  ratio = mpg/weight;
run;

However, because we misspelled the dataset name in the set statement, the new
dataset contains 0 observations.

2    data auto2;
3      set uato;
ERROR: File WORK.UATO.DATA does not exist.
4      ratio = mpg/weight;
5    run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.AUTO2 may be incomplete.  When this step was stopped there were 0
         observations and 7 variables.

The error message indicates that no dataset exists with the name uato
and the warning message hints that the new dataset may be problematic. 
Correcting the spelling solves the problem.

3. Wrong data type

Consider the following data step. It runs without an error message. But does
it give us the intended result?

data test;
  input a b;
cards;
john  1
megan 2
;
run;
proc print data = test;
run;
Obs    a    b

 1     .    1
 2     .    2

Obviously, variable «a» has not been created as desired. This is
because that «a» should be created as a character variable using the
dollar sign specification for character variables. Instead, since the dollar
sign is missing, SAS assumes that «a» is of numeric type, such as an
integer or a real number and SAS expects to encounter a numeric value whenever
it is ready to read in something for «a«. Now, let’s take a look at the
log and see how SAS reacts to not seeing a number for «a«:

2308  data test;
2309   input a b;
2310  cards;

NOTE: Invalid data for a in line 2311 1-4.
RULE:       ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+-
2311        john 1
a=. b=1 _ERROR_=1 _N_=1
NOTE: Invalid data for a in line 2312 1-5.
2312        megan 2
a=. b=2 _ERROR_=1 _N_=2
NOTE: The data set WORK.TEST has 2 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


2313  ;
2314  run;
2315  proc print data = test;
2316  run;

NOTE: There were 2 observations read from the data set WORK.TEST.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

Indeed, there are no error messages in red. But each NOTE offers some
detailed information. The first NOTE says that the data for variable «a»
is invalid in line 2311 position 1-4. Since line 2310 is the line
corresponding to the statement «cards;«, line 2311 corresponds to the
first line of data which starts with input john. So the NOTE is basically
saying that «john» is not a valid numeric value. Once we understand the message,
correcting our code is usually simple enough and in this case, we just need to
add a dollar sign after variable «a»  in the input statement
as shown below.

data test;
 input a $ b;
cards;
john 1
megan 2
;
run;

4. Unmatched quotes/comments

Unclosed quotes and unclosed comments will result in a
variety of errors because SAS will fail to read subsequent statements correctly. If you
are running interactively, your program may appear to be doing nothing, because SAS is
waiting for the end of the quoted string or comment before continuing.  For
example, if we were to run the following program,

proc print data = hsb2 (obs=10);
  var write math;
  title "printing first ten observations';
run;

SAS would not execute the run statement.
Instead it reads it as part of the title statement, because the title statement is missing
the closing double quotes. When this block of code is run, the program would appear to be doing nothing. System
messages would indicate that it is running, which in fact it is. However, SAS
is reading the rest of the program, waiting the double quote that will end the step
it is currently stuck on.

Image errors1

Nothing appears in the output window (not shown).  
If we check the log, it does not have any blue notes indicating that the code
has been executed.

Image errors2

In the program editor window, the font color offers a hint that something is
amiss.  Everything appearing after the opening double quote of the title
appears in purple.  If we correct the program by replacing the single quote with a double
quote, as follows,

proc print data = hsb2 (obs=10);
  var write math;
  title "printing first ten observations";
run;

the program will now run successfully and here is what we should see in the
output:

printing first ten observations                                                                

Obs    write    math

  1      31      44
  2      40      43
  3      65      48
  4      44      49
  5      57      50
  6      41      43
  7      52      41
  8      49      43
  9      59      63
 10      37      42

5. Mixing proc and data statements

Since the data and proc steps perform very different
functions in SAS, statements that are valid for one will probably cause an error when used
in the other. Although a program may include several steps, these steps are processed
separately.

A step ends in one of three ways:

1. SAS encounters a keyword that begins a new step (either proc or
data)
2. SAS encounters the run statement, which instructs it to run the previous step(s)
3. SAS encounters the end of the program.

Each data, proc and run statement causes the previous
step to execute. Consequently, once a new step has begun, you may not go back and add
statements to an earlier step. Consider this program, for example.

data auto2;
   set auto;
proc sort; by make;
   ratio = mpg/weight;
run;

SAS creates the new file auto2 when it reaches the end of the data
step. This occurs when it encounters the beginning of a new step (in this
example proc sort). Consequently, the assignment statement (ratio = mpg/weight;) is
invalid because the data step has been terminated, and an assignment statement cannot be
used in a procedure.

40   data auto2;
41      set auto;

NOTE: The data set WORK.AUTO2 has 26 observations and 5 variables.
NOTE: The DATA statement used 0.12 seconds.

42   proc sort; by make;
43      ratio = mpg/weight;
        ------
        180
44   run;

ERROR 180-322: Statement is not valid or it is used out of proper order.
NOTE: The SAS System stopped processing this step because of errors.

Simply moving the assignment statement solves the problem.

data auto2;
   set auto;
   ratio = mpg/weight;
proc sort; by make;
run;

7. Using options with the wrong proc

Similarly, although many options work with a variety of
procedures, some are only valid when used with a particular procedure. Remember to
evaluate all errors in context. A perfectly correct statement or option may cause an error
not because it is written incorrectly, but because it is being used in the wrong place.

88   proc freq data = auto2;
89   var make;
     ---
     180
90   run;

ERROR 180-322: Statement is not valid or it is used out of proper order.
NOTE: The SAS System stopped processing this step because of errors.

The var statement is not valid when used
with proc freq. Change the statement to tables and the program
runs successfully.

proc freq data = auto2;
  tables make;
run;

Conversely, the tables statement may not
work with other procedures.

92   proc means data = auto2;
93        tables make;
          ------           
          180
94        run;

ERROR 180-322: Statement is not valid or it is used out of proper order.
NOTE: The SAS System stopped processing this step because of errors.

In this example, the var statement is
correct:

proc means data = auto2;
  var make;
run;

8. Logic errors

Consider the log generated when the following program is run:

106  data auto2;
107     set auto;
108     if tons > .5;
109     tons = weight/2000;
110  run;

NOTE: The data set WORK.AUTO2 has 0 observations     

Although the program ran with no errors, the new
data set has no observations in it. Since we would expect most cars to weigh more than
half a ton, there is probably an error in the program logic. In this case, we are
subsetting on a variable that has not yet been defined.

Changing the order of the programming statements yields a different
result:

118  data auto2;
119     set auto;
120     tons = weight/2000;
121     if tons > .5;
122  run;

NOTE: The data set WORK.AUTO2 has 26 observations. 

9. Missing options when dealing with missing data

Consider
following data stored in a text file called test.txt and the data step for
reading the data.

john  11 
megan 22 4
data test;
 infile 'd:temptest.txt';
 input a $ age y;
run;
proc print data = test;
run;

Here is the output from proc print:

Obs     a      age    y

 1     john     11    .

This is obviously not what we have intended. There should be two observations
and there is only one. Most likely this is due to missing data and this is the
case for this example. The value for the variable «y» is missing from row
1. In this case, we need to use the option «missover» of the infile
statement  to instruct SAS not to go a new input line if it does not find
valid values in the current input line.  Here is corrected version of the
code together with the output.

data test;
 infile 'd:temptest.txt' missover;
 input a $ age y;
run;
proc print data = test;
run;
Obs      a      age    y

 1     john      11    .
 2     megan     22    4

10. Not sorting data before using statements that require sort

Although
steps are executed independent of each other, some steps require a previous step
in order to be carried out properly.  A common example is the use of a
by
statement in a data step.  This requires that the data has either
been sorted by the variable(s) in the by statement or that the data was read in
already sorted. If the code below is run without a previous sort on type,

data auto2; set auto;
  by type;
  retain types 0;
  if first.type then types = types + 1;
run;

the log indicates the omission of this step and prints the first line in the
dataset that suggests non-sorted order of the variable(s). 

70   data auto2; set auto;
71       by type;
72       retain types 0;
73       if first.type then types = types + 1;
74   run;

ERROR: BY variables are not properly sorted on data set WORK.AUTO.
Make=Acura Model=NSX coupe 2dr manual S Type=Sports Origin=Asia DriveTrain=Rear MSRP=$89,765
Invoice=$79,978 EngineSize=3.2 Cylinders=6 Horsepower=290 MPG_City=17 MPG_Highway=24 Weight=3153
Wheelbase=100 Length=174 FIRST.Type=0 LAST.Type=1 types=2 _ERROR_=1 _N_=7
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 8 observations read from the data set WORK.AUTO.
WARNING: The data set WORK.AUTO2 may be incomplete.  When this step was stopped there were 6
         observations and 16 variables.
WARNING: Data set WORK.AUTO2 was not replaced because this step was stopped.

Adding a proc sort before this data step corrects this problem.

Blogs

ERROR 180-322: The story of an error message

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

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

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:

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:

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

Impressed that there is a SAS 82.4 version still running. I wonder if any customers are running that version or one in that circa?

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

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

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.

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.

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?

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.

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?

SAS has some PL/1 heritage, but maybe COBOL was an influence as well. All programming languages are related! Well, maybe ALMOST all of them.

Interesting to know some old stuff.. I was not even born in 1982 🙂

Thanks Rahul. You could have kept that nugget to yourself.

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

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

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?

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.

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.

Источник

Create an account to follow your favorite communities and start taking part in conversations.

r/sas

Hey everyone. Hoping for some help. I am trying to run a simple Chi square in SAS (code written below). I keep getting the following error about the second line of code: ERROR 180-322: Statement is not valid or it is used out of proper order. I have tried multiple iterations of playing around with semi colons to no avail. Any help would be greatly appreciated. THANK YOU!

proc freq data=humira_stelara_041820;

 tables gender_numeric*drug_name_numeric / expected chisq;

run;

level 1

if i run your code with my own dataset and variables it works fine, you might need to post a screenshot of your error message.

also double check your gender_numeric/drug_name_numeric variables and humira_stelara_041820 dataset definitely exist

level 2

The dataset and variables were working because I was getting dropdown boxes with the variable names. However, when going to screenshot the error as you suggested I realized that the error was underneath » tables.» There was a space bar causing the issue. Thank you for the help!

level 1

Try exp instead of expected. Is expected blue?

level 2

expected was not blue! I just realized there was a space before tables and now everything seems to be lighting up appropriately. thank you for this callout

level 1

Put chisquare before expected and see if that works.

level 2

Thank you for the suggestion. Just figured out the issue was a space before tables

level 1

How many levels does each variable have? I run into problems with chisq if there are a lot of squares. Try to see if it works with fisher instead of chisq just to test it…

level 2

Thank you for this comment. Each variable only had two levels. But I will keep this in mind for the future!

level 1

Can you show us the code you have just above this? That kind of error often comes when a previous proc/data step is not properly ended (with a semicolon).

level 2

Thank you — this is really good to keep in mind in the future. You were onto something — turns out it was failing due to a space before tables.

level 1

Ngl I thought SAS meant Special Air Service like the British Military.

About Community

A discussion of SAS for data management, statistics, and analysis.



Hello All,

I wondering if someone can help with this unexpected error I am finding with a simple macro code I have. I create 5 datasets m1, m2, m3, m4 and m5 and then use them in an loop inside a macro, but I keep getting Error code 180-322 for the by statement in PROC SORT step.

Code:
%macro reports;

%do k=1 %to 5;
*%let j=1;

proc sort data=m&k. out=m&k.; by descending mark; run;

proc freq data=m&k. order=data;
tables mark /outcum out=d&k.;
run;

proc sort data=d&k.; by descending Mark;
run;
%end;
%mend reports;

data m1;
set all_cand_marks;
if YrGrp in (’12’ ’13’ ’14’ ’15’ ’99’);
run;

data m2;
set all_cand_marks;
if YrGrp in (’11’);
run;

data m3;
set all_cand_marks;
if YrGrp in(’10’);
run;

data m4;
set all_cand_marks;
if YrGrp in (’09’);
run;

data m5;
set all_cand_marks;
if YrGrp in (’00’);
run;

/* cycle round data by year group to produce all distribution. */

%report;

It gives the following Log :
245
246 data m5;
247 set all_cand_marks;
248 if YrGrp in (’00’);
249 run;

NOTE: There were 377 observations read from the data set WORK.ALL_CAND_MARKS.
NOTE: The data set WORK.M5 has 0 observations and 14 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

250
251
252 /* cycle round data by year group to produce all distribution. */
253
254
255
256 %reports;
NOTE: Line generated by the invoked macro «»REPORTS»».
3 proc sort data=m&k. out=m&k.; by descending mark;

180

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

NOTE: There were 59 observations read from the data set WORK.M1.
NOTE: The data set WORK.D1 has 26 observations and 5 variables.
NOTE: PROCEDURE FREQ used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

NOTE: There were 26 observations read from the data set WORK.D1.
NOTE: The data set WORK.D1 has 26 observations and 5 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

NOTE: Line generated by the invoked macro «»REPORTS»».
7 proc sort data=m&k. out=m&k.; by descending mark;

180

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

I am unable to understand why its having a problem with the by statement in the PROC SORT step.

Any help is much appreciated.
Regards,
Parvathi

Read these next…

  • Curated Green Brand Rep Wrap-Up: January 2023

    Green Brand Rep Wrap-Up: January 2023

    Spiceworks Originals

    Hi, y’all — Chad here. A while back, we used to feature the top posts from our brand reps (aka “Green Gals/Guys/et. al.) in a weekly or monthly wrap-up post. I can’t specifically recall which, as that was approximately eleven timelines ago. Luckily, our t…

  • Curated Help with domain controller setup

    Help with domain controller setup

    Windows

    I just got a new job as the only IT person for a business with around 270 employees (I would say probably less than half use computers) They don’t have any policies or procedures when it comes to IT, as they have never had an IT person. My background cons…

  • Curated Malicious URLs

    Malicious URLs

    Security

    We have firewall, we have endpoint protection, we have Safe links and Attachments for Office 365 (Microsoft Defense for Office 365 Plan 1), and still receiving links that lead to malicious web sites.It seems like security companies still didn’t develop a …

  • Curated Snap! -- Old Batteries, Lovable Bots, Quantum Breakthrough, Should We Trust AI?

    Snap! — Old Batteries, Lovable Bots, Quantum Breakthrough, Should We Trust AI?

    Spiceworks Originals

    Your daily dose of tech news, in brief.

    Welcome to the Snap!

    Flashback: February 8, 1996: The massive Internet collaboration “24 Hours in Cyberspace” takes place (Read more HERE.)

    Bonus Flashback: February 8, 1974: Americans end outer spa…

  • Curated Large collection of Mac Minis

    Large collection of Mac Minis

    Best Practices & General IT

    We are getting rid of a lot of older equipment that doesn’t have a purpose anymore on our campus. Most of it is 2010 and 2014 Mac Minis. When they were purchased, they were the absolute base model, so nothing special about them. I’ve reached out to multip…

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Error 18 больше файлов не осталось
  • Error 18 calypso crossout
  • Error 18 at 0 depth lookup self signed certificate
  • Error 1783 the stub received bad data
  • Error 1772 there is a problem with this windows installer package

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии