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.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.