Hi all,
I'm currently attempting to group observations where the days between observations is less than 10. The new column can be called group. I would like the title of the observations in a group to be the earliest date according to start_lactation. In the case of the data below, I would like observations 1-4 with the group column titled as 05/02/2011. Observations 5-7 should be left as blank. Observations 8 and 9 should be titled as 08/10/2011. Observations 10-15 should be titled as 25/01/2012. I need to do this for thousands of observations. I'm using sas 9.4.
Any help is greatly appreciated
data WORK.X;
infile datalines dsd truncover;
input TECHID:13. START_LACTATION:DDMMYY10. Daysapart:32.;
format TECHID 13. START_LACTATION DDMMYY10.;
label TECHID="TECHID";
datalines;
669222149 05/02/2011 .
669222145 05/02/2011 0
669222150 08/02/2011 3
669823432 10/02/2011 2
671847527 21/02/2011 11
669819685 17/03/2011 24
669819684 20/04/2011 34
669222144 08/10/2011 171
676229644 14/10/2011 6
748982347 25/01/2012 103
748982346 25/01/2012 0
744293316 26/01/2012 1
746731229 26/01/2012 0
748465662 27/01/2012 1
744813559 28/01/2012 1