Hi everyone,
A sample of my data looks as follows (my current data ). As you can see, the person 1's starting health status (health_1) is H (healthy) in 2000 then becomes U (unhealthy) in 2002 and again H (healthy) in 2004. I would like to generate a new health variable (e.g., health_2) that reads that person's health status in 2000 as U which equals his/her health status in 2002 and so one. Additionally, If the person dies then the health_2 is U rather than missing.
Thanks,
Nader
*My current data
clear all
input id year str6 (health_1)
1 2000 "H"
1 2002 "U"
1 2004 "H"
2 2000 "H"
2 2002 "H"
3 2000 "H"
3 2002 "H"
3 2004 "H"
end
list
*My goal
clear all
input id year str6 (health_1 health_2)
1 2000 "H" "U"
1 2002 "U" "H"
1 2004 "H" "."
2 2000 "H" "H"
2 2002 "H" "."
3 2000 "H" "H"
3 2002 "H" "H"
3 2004 "H" "."
end
list
Related Posts with recoding a new generated variable
System GMM with panel dataHi I had run a system GMM panel data regression on STATA 14 and I got Variance-covariance matrix o…
Need to Highlight specific points on scatter plot, trying to create new variableHello, beginner to STATA and coding in general. I have a dataset with countries. I created a new var…
Doing endogenous regime switching regressionPlease can you help me with these questions? 1. What STATA command can I use to run an endogenous re…
Random effect model - controlling for timeHy folks, i have the following panel data: ID Birthyear Year of Assessment Fahter played footba…
How to plot an interaction term in multinomial logistic regression model ?Dear statalists, Hope this post finds you well. I have tried to plot a graph with an interaction …
Subscribe to:
Post Comments (Atom)
0 Response to recoding a new generated variable
Post a Comment