Hi all,
I have a data set as below. I want to compare t and l1-3 and then assign a new variable called pl. When i do that i am getting a message saying that "Expecting an arithmetic operator" and underlies l1,l2,l3, and l4. What am i doing wrong?
Thanks
data set:
t l1 l2 l3 l4
-1.2 -1.2 0.5 0.2 0.1
-1.1 -1.2 0.5 0.2 0.1
-1.0 -1.2 0.5 0.2 0.1
-1.3 -1.2 0.5 0.2 0.1
-1.4 -1.2 0.5 0.2 0.1
data dd4;
set dd03;
if t lt l1 then pl="Level 1";
else if t ge l2 and lt l3 then pl="Level 2";
else if t ge l3 and lt l4 then pl="Level 3";
else if t ge l4 then pl="Level 4";
Incorrect syntax.
else if t ge l2 and lt l3 then pl="Level 2";
Should be:
else if l2 <= t < l3 then pl="Level 2";
Or more verbose
else if t ge l2 and t lt l3 then pl="Level 2";
@dustychair wrote:
Hi all,
I have a data set as below. I want to compare t and l1-3 and then assign a new variable called pl. When i do that i am getting a message saying that "Expecting an arithmetic operator" and underlies l1,l2,l3, and l4. What am i doing wrong?
Thanks
data set:
t l1 l2 l3 l4
-1.2 -1.2 0.5 0.2 0.1
-1.1 -1.2 0.5 0.2 0.1
-1.0 -1.2 0.5 0.2 0.1
-1.3 -1.2 0.5 0.2 0.1
-1.4 -1.2 0.5 0.2 0.1
data dd4; set dd03; if t lt l1 then pl="Level 1"; else if t ge l2 and lt l3 then pl="Level 2"; else if t ge l3 and lt l4 then pl="Level 3"; else if t ge l4 then pl="Level 4";
Incorrect syntax.
else if t ge l2 and lt l3 then pl="Level 2";
Should be:
else if l2 <= t < l3 then pl="Level 2";
Or more verbose
else if t ge l2 and t lt l3 then pl="Level 2";
@dustychair wrote:
Hi all,
I have a data set as below. I want to compare t and l1-3 and then assign a new variable called pl. When i do that i am getting a message saying that "Expecting an arithmetic operator" and underlies l1,l2,l3, and l4. What am i doing wrong?
Thanks
data set:
t l1 l2 l3 l4
-1.2 -1.2 0.5 0.2 0.1
-1.1 -1.2 0.5 0.2 0.1
-1.0 -1.2 0.5 0.2 0.1
-1.3 -1.2 0.5 0.2 0.1
-1.4 -1.2 0.5 0.2 0.1
data dd4; set dd03; if t lt l1 then pl="Level 1"; else if t ge l2 and lt l3 then pl="Level 2"; else if t ge l3 and lt l4 then pl="Level 3"; else if t ge l4 then pl="Level 4";
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.