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;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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