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

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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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