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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.