Hello, all,
I've got some panel data for a randomized trial, and I'm trying to link the data to the diagnoses in Medicare claims files. I have flags for whether a person meets the diagnostic criteria for a number of chronic conditions in the current year. I would like to create a flag indicating that someone has had a disease that turns on when they get the disease in one year, and then stays on, regardless of whether they currently have the disease.
For example, consider dementia, which is often not coded in medical claims. Say I'm willing to assume that once someone has been flagged as having dementia in 2001, they probably still have it even if the 2003 medical claims don't say they do. However, I don't want their line for the year 2000 to say that they do.
I currently have the first 3 columns, and I'm trying to create the 4th.
I believe that this will accomplish my goal, and I'd like to ask if people think this is correct:
tsset ID year
gen dementiaprior = currentdementia
replace dementiaprior = L.dementiaprior if dementiaprior == 0 & L.dementiaprior == 1
This appears to work in the test data I've set up (which is in Stata 11 format), and from the tsset documentation, it appears that the xt suite of commands (e.g. xtgee and xtregress) will work after I've tsset the data. Am I right? If I am, can anyone think of a more parsimonious way to do this?
Thanks for any assistance you can provide.
I've got some panel data for a randomized trial, and I'm trying to link the data to the diagnoses in Medicare claims files. I have flags for whether a person meets the diagnostic criteria for a number of chronic conditions in the current year. I would like to create a flag indicating that someone has had a disease that turns on when they get the disease in one year, and then stays on, regardless of whether they currently have the disease.
For example, consider dementia, which is often not coded in medical claims. Say I'm willing to assume that once someone has been flagged as having dementia in 2001, they probably still have it even if the 2003 medical claims don't say they do. However, I don't want their line for the year 2000 to say that they do.
I currently have the first 3 columns, and I'm trying to create the 4th.
Name | Year | Current Dementia | Dementia Now or Prior |
Mrs Vang | 2000 | 0 | 0 |
Mrs Vang | 2001 | 1 | 1 |
Mrs Vang | 2002 | 0 | 1 |
Mrs Vang | 2003 | 0 | 1 |
tsset ID year
gen dementiaprior = currentdementia
replace dementiaprior = L.dementiaprior if dementiaprior == 0 & L.dementiaprior == 1
This appears to work in the test data I've set up (which is in Stata 11 format), and from the tsset documentation, it appears that the xt suite of commands (e.g. xtgee and xtregress) will work after I've tsset the data. Am I right? If I am, can anyone think of a more parsimonious way to do this?
Thanks for any assistance you can provide.
Comment