Hi,
I am trying to generate a variable "Desired Output" that tells me if an observation "identification" on an ID basis (identification that might take value from 1 to n) at year 2010 is also present at 2009. In this case, I want STATA to return me the value "No changes", while if the observation is only present at year 2010 and not at year 2009 (means that has been deleted) I want the value "Added". This comparison has to be done for 2010 vs 2009 and 2011 vs 2010 and so on on a ID basis. Of course for the first year of observations per ID there is no output "na" and the first year might be 2009, 2010 or 2011 depending on the ID.
Thank you
Best
Alberto
I am trying to generate a variable "Desired Output" that tells me if an observation "identification" on an ID basis (identification that might take value from 1 to n) at year 2010 is also present at 2009. In this case, I want STATA to return me the value "No changes", while if the observation is only present at year 2010 and not at year 2009 (means that has been deleted) I want the value "Added". This comparison has to be done for 2010 vs 2009 and 2011 vs 2010 and so on on a ID basis. Of course for the first year of observations per ID there is no output "na" and the first year might be 2009, 2010 or 2011 depending on the ID.
ID | Year | Identification | Desired Output |
3242 | 2009 | 1 | na |
3242 | 2009 | 2 | na |
3242 | 2010 | 1 | No Changes |
3242 | 2010 | 2 | No Changes |
3242 | 2010 | 3 | Added |
3242 | 2011 | 3 | No Changes |
3242 | 2011 | 4 | Added |
5566 | 2010 | 2 | na |
5566 | 2011 | 1 | Added |
5566 | 2011 | 3 | Added |
5566 | 2012 | 1 | No Changes |
5566 | 2012 | 3 | No Changes |
5566 | 2012 | 4 | Added |
Best
Alberto
Comment