DATA Step, Macro, Functions and more

conditional statements

Reply
Super Contributor
Posts: 285

conditional statements

[ Edited ]

 Hello,

 

Are below two DATA step (test1, test2) same ? I am assuming the NOT FIRST.ID  is implied in test2.

 


data test;
input id x;
cards;
1 2
1 2
2 3
2 2
;
run;

data test1;
set test;
by id;
retain val;
if first.id then val = 1;
else if not first.id and x > 1 then val = 5;
run;

data test2;
set test;
by id;
retain val;
if first.id then val = 1;
else if x > 1 then val = 5;
run;
Super User
Posts: 24,028

Re: conditional statements

Posted in reply to SAS_inquisitive

Yes, because the only way to enter the second condition is if it's not first.ID. 

 

 

Ask a Question
Discussion stats
  • 1 reply
  • 97 views
  • 1 like
  • 2 in conversation