I have a long dataset, and I want to create a dummy variable to indicate whether a participant reached the close-out phase of the study. So if any status="Close-out", dummy=1. If status never equals "Close-out", dummy=0. How can I generate this dummy variable?
Code:
* Example generated by -dataex-. For more info, type help dataex clear input int study_id str9 status 1127 "Follow-up" 1127 "Close-out" 1250 "Follow-up" 1250 "Close-out" 1619 "Follow-up" 1619 "Close-out" 1639 "Close-out" 1639 "Follow-up" 1747 "Follow-up" 1747 "Close-out" 1751 "PT2" 1769 "PT2" 1777 "PT2" 1802 "PT2" 1817 "PT2" 1872 "Follow-up" 1872 "Close-out" 1943 "Close-out" 1943 "Follow-up" 1944 "PT2" 1945 "Follow-up" 1945 "Close-out" 1955 "Close-out" 1955 "Follow-up" 1956 "Close-out" 1956 "Follow-up" 1996 "PT2" 1996 "Follow-up" 1996 "Close-out" 2002 "Close-out" 2002 "Follow-up" 2023 "Close-out" 2023 "Follow-up" 2030 "Close-out" 2030 "PT2" 2030 "Follow-up" 2031 "PT2" 2031 "Follow-up" 2031 "Close-out" 2042 "Close-out" 2042 "Follow-up" 2055 "Follow-up" 2055 "Close-out" 2055 "PT2" 2061 "Close-out" 2061 "Follow-up" 2079 "Close-out" 2079 "Follow-up" 2128 "Close-out" 2128 "Follow-up" 2140 "Close-out" 2140 "Follow-up" 2148 "Close-out" 2161 "Close-out" 2161 "Follow-up" 2183 "Close-out" 2183 "Follow-up" 2183 "Close-out" 2183 "Follow-up" 2199 "Follow-up" 2199 "Close-out" 2204 "Close-out" 2204 "Follow-up" 2211 "Close-out" 2211 "Follow-up" 2211 "PT2" 2223 "Follow-up" 2223 "Close-out" 2234 "PT2" 2234 "Close-out" 2238 "Close-out" 2238 "Follow-up" 2259 "Close-out" 2259 "Follow-up" 2268 "Close-out" 2268 "Follow-up" 2280 "Close-out" 2280 "Follow-up" 2350 "Baseline" 2355 "Follow-up" 2355 "PT2" 2355 "Close-out" 2362 "Close-out" 2363 "Close-out" 2363 "PT2" 2363 "Follow-up" 2368 "Close-out" 2368 "Follow-up" 2369 "Follow-up" 2369 "PT2" 2369 "Close-out" 2370 "Follow-up" 2370 "Close-out" 2370 "PT2" 2372 "Close-out" 2388 "PT1" 2388 "Baseline" 2388 "Close-out" 2388 "Follow-up" 2388 "PT2" end
Comment