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. 

 

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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