BookmarkSubscribeRSS Feed
robertrao
Quartz | Level 8

Hello,

 

I am trying to write a logic and have been getting an error. "statement is not valid or it is used out of proper order"

Could you help me figure out the mistake in these statements

 

data want;

set have;

IF (PalS_N/19 > .50) THEN
PalS = SUM(PAL1,PAL2,PAL3,PAL4, B1, PAL5, C2, O2, PAL6, PAL7, Br7, PAL8, PAL9,PAL10, Sp21, PAL12, L1, PAL13, PAL14)*19/(PalS_N);
ELSE IF (PalS_N/19 < .50) THEN PalS =SUM(PAL1,PAL2,PAL3,PAL4, B1, PAL5, C2, O2, PAL6, PAL7, Br7, PAL8, PAL9,PAL10, Sp21, PAL12, L1, PAL13, PAL14);

run;
run;

5 REPLIES 5
Reeza
Super User

Show your log. And what happens if it equals 0.5?

 


@robertrao wrote:

Hello,

 

I am trying to write a logic and have been getting an error. "statement is not valid or it is used out of proper order"

Could you help me figure out the mistake in these statements

 

data want;

set have;

IF (PalS_N/19 > .50) THEN
PalS = SUM(PAL1,PAL2,PAL3,PAL4, B1, PAL5, C2, O2, PAL6, PAL7, Br7, PAL8, PAL9,PAL10, Sp21, PAL12, L1, PAL13, PAL14)*19/(PalS_N);
ELSE IF (PalS_N/19 < .50) THEN PalS =SUM(PAL1,PAL2,PAL3,PAL4, B1, PAL5, C2, O2, PAL6, PAL7, Br7, PAL8, PAL9,PAL10, Sp21, PAL12, L1, PAL13, PAL14);

run;
run;


 

robertrao
Quartz | Level 8

Thanks Reeza for the reply.

 

If it equals 0.5 then it is to be included in the less than or equal to category (PalS_N/19 <= .50).

 

The following is the error

 

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

Reeza
Super User
Please post the full log. Where the error occurs tells you where the error is.
robertrao
Quartz | Level 8

Thanks Reeza,

 

It finally worked. I had some RUN statements in between the statements and forgot to remove them !!!!

This statement worked!!!

 

IF (PalS_N/19 > .50) THEN
PalS = SUM(PAL1,PAL2,PAL3,PAL4, B1, PAL5, C2, O2, PAL6, PAL7, Br7, PAL8, PAL9,PAL10, Sp21, PAL12, L1, PAL13, PAL14)*19/(PalS_N);
ELSE PalS =SUM(PAL1,PAL2,PAL3,PAL4, B1, PAL5, C2, O2, PAL6, PAL7, Br7, PAL8, PAL9,PAL10, Sp21, PAL12, L1, PAL13, PAL14);

 

mkeintz
PROC Star

@robertrao 

 

I hope you regard your discovery of the problem diagnosis and fix as a demonstration of the wisdom of @Reeza 's request for the full log.

 

I do.

 

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 5 replies
  • 950 views
  • 4 likes
  • 3 in conversation