good day,
here is my program,
data have;
input name $40.;
infile datalines dlm=',';
datalines;
A
AAAOTAXIUNION
AACARPETSDELHI
AADESIGNFURNZTURNSAMUTPRAKAN
AADRIVERTRAININGLTAUCKLAND
AAFOOTWEARCENTRALWORBANGKOK
AAFOOTWEARGAYSORNBANGKOK
AAFOOTWEAROUTLETAYUTTAYUTTHAYA
AAHONGKONG
AAMCLENNANGKMPOKOLBIN
;
run;
data have2;
set have;
lag_name=lag(name);
run;
i also want to add a lead Row here for comparison. can anyone help?
thanks in advance
Try this
data have2;
merge have
have(firstobs=2 rename=(name=lead_name) keep=name);
lag_name=lag(name);
run;
Try this
data have2;
merge have
have(firstobs=2 rename=(name=lead_name) keep=name);
lag_name=lag(name);
run;
HI @harrylui
Could you try the same code with the following option before:
Options mergeNoBy=noWarn ;
Please check that the MERGENOBY System Option is set to NOWARN.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.