I am conducting a study to track people's health condition changes. Data will be look like the one below. My goal is to find the first year that the condition changed. For example, for person 1, first year of change is 2001; person 2: never changed; person 5: 2002; ... Maybe it is good idea to create a variable at the end, say "first_yr" which contains the year of first change. The same analysis will be conducted for subsample that includes all individuals without missing information. My real data has more years and observations, I tried to use loop and kind of lost tracking. Any help will be great! thanks.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte id str1(h_2000 h_2001 h_2002 h_2003) 1 "a" "b" "b" "a" 2 "c" "" "c" "c" 3 "d" "e" "d" "d" 4 "f" "" "f" "f" 5 "g" "" "h" "g" 6 "b" "b" "b" "g" end
Comment