Dear All: May data is as follows Date ID Time 22OCT2018 A 9:00 22OCT2018 A 9:00 22OCT2018 A 9:01 22OCT2018 A 9:02 22OCT2018 B 9:08 22OCT2018 B 9:09 22OCT2018 B 9:10 22OCT2018 B 9:10 I want to construct a variable that groups the ID's by time Date ID Time Group 22OCT2018 A 9:00 1 22OCT2018 A 9:00 1 22OCT2018 A 9:01 2 22OCT2018 A 9:02 3 22OCT2018 B 9:08 1 22OCT2018 B 9:09 2 22OCT2018 B 9:10 3 22OCT2018 B 9:10 3
Please Help.
Thanx
Randy
data have;
input Date : date9. ID $ Time :time5.;
format date date9. Time time5.;
cards;
22OCT2018 A 9:00
22OCT2018 A 9:00
22OCT2018 A 9:01
22OCT2018 A 9:02
22OCT2018 B 9:08
22OCT2018 B 9:09
22OCT2018 B 9:10
22OCT2018 B 9:10
;
data want;
set have;
by id time;
if first.id then group=1;
else if first.time then group+1;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.