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;
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;
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.
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);
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.