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";
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: