My data is currently in the form:
ID Fill1 Fill2 Fill3 Fill4 Fill5
1 01JAN2014 28JAN2014 26FEB2014 . .
2 . 05FEB2012 03MAR2012 02APR2012 01MAY2012
3 10MAR2015 08APR2015 07MAY2015 05JUN2015 03JUL2015
4 . . 20FEB2013 18MAR2013 .
And I am trying to create treatment "episodes" per ID. In other words, for each ID I want to find the first and last non-empty Fills and then calculate the difference between the two dates. For example for ID=1 I need to find the time difference between 01JAN2014 and 26FEB2014. That is,
Fill1 - Fill3 = episodeduration
but for ID=4 I would need to find,
Fill3 - Fill4 = episodeduration
where episodeduration is a new variable created. I have over 30k unique IDs with varying "first" and "last" Fill dates. Thanks in advance for you help.