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.
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.
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.