Hello!
I am working with a dataset with about 25,000 observations for about 5500 unique id’s.
I have several date variables (datevarX) and each id has multiple dates, and for some id’s the datevar is missing.
I am using this code to identify the first date per id:
If seq==1 & datevar1!=. this is the first date per id.
I need help to identify the latest (opposite of the first) date per id of datevar2
Once I can identify both the first date of datevar1 and the latest date of datevar2 I want to generate a variable that expresses the duration between datevar2 and datevar1 per id., which I think should be straight forward as long as I only have 1 date per id.
I am using Stata/IC 13.1 for Mac.
Kind regards,
Stine Nielsen
I am working with a dataset with about 25,000 observations for about 5500 unique id’s.
I have several date variables (datevarX) and each id has multiple dates, and for some id’s the datevar is missing.
I am using this code to identify the first date per id:
Code:
bysort id (datevar1) : gen seq=_n
I need help to identify the latest (opposite of the first) date per id of datevar2
Once I can identify both the first date of datevar1 and the latest date of datevar2 I want to generate a variable that expresses the duration between datevar2 and datevar1 per id., which I think should be straight forward as long as I only have 1 date per id.
I am using Stata/IC 13.1 for Mac.
Kind regards,
Stine Nielsen
Comment