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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.