Please explain the value "1_0" in the second observation in more detail.
OK, and what is the zero?
Try this
data have;
input ID $ Number;
datalines;
A 1
A 2
A 5
A 19
A 19
B 1
B 3
;
data want;
set have;
by ID;
if dif(Number) not in (0, 1) then numberoftimes + 1;
if first.ID then numberoftimes = 0;
run;
Result:
ID Number numberoftimes A 1 0 A 2 0 A 5 1 A 19 2 A 19 2 B 1 0 B 3 1
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.