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;
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!