data have;
input gender $1. age 3. name :$7.;
datalines;
F 2 Patsy
F 2 Patsy
F 2 Pat
M 3 Steve
;
run;
proc sort data = have;
by name;
run;
data want;
set have;
by name;
if first.name then counter = 1;
else counter + 1;
run;
Obs gender age name counter 1 F 2 Pat 1 2 F 2 Patsy 1 3 F 2 Patsy 2 4 M 3 Steve 1
proc sort data=have;
by name;
run;
data have2;
set have;
by name;
if first.name ne last.name then diff_flag=1;
run;
Which one though? Does it matter? You don't specify.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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 save with the early bird rate—just $795!
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.