BookmarkSubscribeRSS Feed
SAS_inquisitive
Lapis Lazuli | Level 10

 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;
1 REPLY 1
Reeza
Super User

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

 

 

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
  • 1 reply
  • 854 views
  • 1 like
  • 2 in conversation