BookmarkSubscribeRSS Feed
shimelis
Calcite | Level 5

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!

4 REPLIES 4
ballardw
Super User

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.

 

Astounding
PROC Star

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.

shimelis
Calcite | Level 5
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!
ballardw
Super User

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 989 views
  • 5 likes
  • 3 in conversation