DATA Step, Macro, Functions and more

Error while running proc means

Reply
Occasional Contributor
Posts: 9

Error while running proc means

[ Edited ]

Hello Sas community; /* gives a summary of a variable age */ Every time I run this code,it gives an error saying VAR AGE IS OUT OF ORDER.

 

 PROC MEANS DATA = sun.demographics NWAY MISSING; 
N NMISS MEAN MIN P1 P5 P10 P25 P50 P75 P90 P95 P99 MAX;
 VAR AGE;;
 RUN;

 

Where as when I run this code , it gives an output.:

PROC MEANS DATA = sun.demographics NWAY MISSING;
 VAR AGE;; 
RUN; 

 

Please can somebody explain why the first code keeps giving me an error? with Regards!

Super User
Posts: 10,466

Re: proc means

The code that doesn't run:

 PROC MEANS DATA = sun.demographics NWAY MISSING; N NMISS MEAN MIN P1 P5 P10 P25 P50 P75 P90 P95 P99 MAX;

Has a ; after missing. That ends the Proc means statement.

 

You are likely misunderstanding that an error message like:

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

 

Is actually referring to the line Above where the message appears in the log. There should be an underscore under the N. That indicates that the place you referred to the N statistic is incorrect.

 

Super User
Posts: 5,071

Re: Error while running proc means

In addition to the extra semicolon, note that the message you got is consistent with your actual program containing this statement:

 

BY AGE;

 

If that statement appears in the code, it needs to come out.  The VAR statement is correct.

Occasional Contributor
Posts: 9

proc means help

Hello SAS community; /* gives a summary of a variable age */ Every time I run this code one, it gives an error saying VAR AGE IS OUT OF ORDER. Code1 PROC MEANS DATA = sun.demographics NWAY MISSING; N NMISS MEAN MIN P1 P5 P10 P25 P50 P75 P90 P95 P99 MAX; VAR AGE; RUN; Whereas when I run this code2, it gives an output. Code2 PROC MEANS DATA = sun.demographics NWAY MISSING; VAR AGE; RUN; Please, can somebody explain why the first code keeps giving me an error? with Regards!
Super User
Posts: 10,466

Re: proc means help

Please post your code using the input box opened by  "running man" icon on the top row. Your unformatted code is very hard to read.

And the question has been answered.

Ask a Question
Discussion stats
  • 4 replies
  • 252 views
  • 5 likes
  • 3 in conversation