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
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.