BookmarkSubscribeRSS Feed
HansSteenhuis
Calcite | Level 5

Hello everyone,

 

Is it possible to apply this function that I have in Excel in EG?

 

NUMBER CODE IF statement
1410647 313  
1410647 322 313
1411948 313  
1411948 320 313
1411950 322  
1411950 303 322
1412210 318  
1412210 313 318
1412210 320 313
1412210 312 320
1598745 314  
1598745 380 314
1598745 312 380
1598745 314 312
1598745 380 314
1598745 380 380
1598745 314 380
1598745 380 314

 

regards,

 
 

Hans

 

1 REPLY 1
jebjur
SAS Employee

I think you can use a combination of BY group processing and the LAG function to get the results you want.

 

proc sort data=one;
by number;
run;

 

data two;
set one;
by number;
y=lag(code);
if first.number then y=.;
run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 664 views
  • 0 likes
  • 2 in conversation