Hi there,
I have a list of observations in a .csv including date fields for each observation under the headings "observation id", "date" (dd/mm/yy)
The dates range from 01/09/11 to 01/09/16 but I only want to use the mm/yy portion
Assuming that once the observation happens it is added to a fixed stock, I'm trying to generate dummy variables from these dates to provide a sort of cumulative measure.
As such, If an observation was recorded in 01/14 I would want to have dummy variables that displayed "0" for each month from the beginning of the period up to December 2013 and then "1" for each month from January 2014 to the end of the period (09/16)
Is there any way that this can be achieved in Stata?
In theory, I guess this is what it would need to end up looking like:
Thanks in advance
I have a list of observations in a .csv including date fields for each observation under the headings "observation id", "date" (dd/mm/yy)
The dates range from 01/09/11 to 01/09/16 but I only want to use the mm/yy portion
Assuming that once the observation happens it is added to a fixed stock, I'm trying to generate dummy variables from these dates to provide a sort of cumulative measure.
As such, If an observation was recorded in 01/14 I would want to have dummy variables that displayed "0" for each month from the beginning of the period up to December 2013 and then "1" for each month from January 2014 to the end of the period (09/16)
Is there any way that this can be achieved in Stata?
In theory, I guess this is what it would need to end up looking like:
id | date | 09/09 | … | 09/10 | 10/12 | 11/12 | … | 09/16 |
717308 | 20/10/2012 | 0 | 0 | 0 | 1 | 1 | 1 | 1 |
705526 | 20/10/2012 | 0 | 0 | 0 | 1 | 1 | 1 | 1 |
705210 | 20/10/2012 | 0 | 0 | 0 | 1 | 1 | 1 | 1 |
680739 | 20/10/2012 | 0 | 0 | 0 | 1 | 1 | 1 | 1 |
672080 | 20/10/2012 | 0 | 0 | 0 | 1 | 1 | 1 | 1 |
521029 | 21/10/2012 | 0 | 0 | 0 | 1 | 1 | 1 | 1 |
613404 | 21/10/2012 | 0 | 0 | 0 | 1 | 1 | 1 | 1 |
402700 | 21/10/2012 | 0 | 0 | 0 | 1 | 1 | 1 | 1 |
740867 | 22/10/2012 | 0 | 0 | 0 | 1 | 1 | 1 | 1 |
727655 | 22/10/2012 | 0 | 0 | 0 | 1 | 1 | 1 | 1 |
450370 | 22/11/2012 | 0 | 0 | 0 | 0 | 1 | 1 | 1 |
632672 | 22/11/2012 | 0 | 0 | 0 | 0 | 1 | 1 | 1 |
731022 | 22/11/2012 | 0 | 0 | 0 | 0 | 1 | 1 | 1 |
539042 | 22/11/2012 | 0 | 0 | 0 | 0 | 1 | 1 | 1 |
Comment