Hi everyone,
I am analyzing mortality data from the National Health Interview Survey. The public use data file includes year of interview and year of death. I want to use these two variables to calculate duration of follow-up using these criteria:
a) if the respondent died in the same year when they were interviewed, assign 0.5 years of follow-up time.
b) assign all others, 0.5 years of follow-up time during the year of their interview, full year of follow-up for each year after their year of interview, until the year prior to their death, and then another 0.5 year of follow-up during the year of their death.
As you can see in the screenshot below among those who were interviewed in 1986, 168 died the same year. Of the remaining, 385 died the next year; 481 the following year and so on.
[ATTACH=CONFIG]temp_12908_1545788917819_951[/ATTACH]
Both year variables (year of interview and year of death) are numeric. I generated a new variable by taking the difference between the two year variables and assigned a value 0.5 if the difference was 0. But am having a hard time creating a loop to automate the process to complete (b). Any help is greatly appreciated. I'm using Stata 14 on Windows 10.
Thanks,
Ahmed
Related Posts with Calculating person years
How to replace inconsistent identity code with the majority identity within 6 years?I have 140,000 firms for 2010-2015. I want to check whether the industrial code (indcode) is consist…
sem vs gsem?Hi everyone. I want to use sem or gsem to evaluate the associations of different patterns of weight …
Generating a variable to count # of "ideal" in each category per observationDear all, I have three variables(idealFruitVeg ; idealfiber ; idealssbweek). Each variable can have…
Seeking an efficient way to establish auxiliary time scales refrenced to data elementsI have been working for 2 + years with data generated from a custom app seeking improvement in treat…
Rounding with a macroHi, To display a number rounded down to a user selected number of decimal places, I wrote some code…
Subscribe to:
Post Comments (Atom)
0 Response to Calculating person years
Post a Comment