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;
Navigate AI governance with SAS tools for compliance and ethical AI practices. Try SAS Ai Navigator for free for the first six months.
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.