Hello Statalisters,
I need to recode a variable to indicate the number of days that elapsed to the adoption of a particular policy. Currently, the variable first_public_healthpost is coded 0 or 1, with 1 indicating when the policy was adopted. I have a variable daily_cases_by_date that's tracking the passage of time. I believe to recode this variable I need to do something like: gen daystopassage= daily_cases_by_date-first_public_healthpost==1 but when I do this, all I get is a bunch of zeros in the new variable when I expect that starts at 1 to the number of elapsed days to passage. I know this should be fairly simple but I'm stuck. Any assistance would be greatly appreciated. Data sample included below:
So basically all I need to do is create a new variable that counts from the daily_cases_by_date up to the date of the first_public_healthpost to run a Cox-Hazard model of this data. I'm interested in the differences in time to adoption amongst the states.
I need to recode a variable to indicate the number of days that elapsed to the adoption of a particular policy. Currently, the variable first_public_healthpost is coded 0 or 1, with 1 indicating when the policy was adopted. I have a variable daily_cases_by_date that's tracking the passage of time. I believe to recode this variable I need to do something like: gen daystopassage= daily_cases_by_date-first_public_healthpost==1 but when I do this, all I get is a bunch of zeros in the new variable when I expect that starts at 1 to the number of elapsed days to passage. I know this should be fairly simple but I'm stuck. Any assistance would be greatly appreciated. Data sample included below:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float daily_cases_by_date int day byte(fips2 first_public_healthpost mandate_order_dates) str14 name 22085 150 1 0 0 "Alabama" 22086 151 1 0 0 "Alabama" 22087 152 1 0 0 "Alabama" 22088 153 1 0 0 "Alabama" 22089 154 1 0 0 "Alabama" 22090 155 1 0 0 "Alabama" 22091 156 1 0 0 "Alabama" 22092 157 1 0 0 "Alabama" 22093 158 1 0 0 "Alabama" 22094 159 1 0 0 "Alabama" 22095 160 1 0 0 "Alabama" 22096 161 1 0 0 "Alabama" 22097 162 1 0 0 "Alabama" 22098 163 1 0 0 "Alabama" 22099 164 1 0 0 "Alabama" 22100 165 1 0 0 "Alabama" 22101 166 1 0 0 "Alabama" 22102 167 1 0 0 "Alabama" 22103 168 1 0 0 "Alabama" 22104 169 1 0 0 "Alabama" 22105 170 1 0 0 "Alabama" 22106 171 1 0 0 "Alabama" 22107 172 1 0 0 "Alabama" 22108 173 1 0 0 "Alabama" 22109 174 1 0 0 "Alabama" 22110 175 1 0 0 "Alabama" 22111 176 1 0 0 "Alabama" 22112 177 1 1 1 "Alabama" 22113 178 1 1 1 "Alabama" 22114 179 1 1 1 "Alabama" 22115 180 1 1 1 "Alabama" 22116 181 1 1 1 "Alabama" 22117 182 1 1 1 "Alabama" 22118 183 1 1 1 "Alabama" 22119 184 1 1 1 "Alabama" 22120 185 1 1 1 "Alabama" 22121 186 1 1 1 "Alabama" 22122 187 1 1 1 "Alabama" 22123 188 1 1 1 "Alabama" 22124 189 1 1 1 "Alabama" 22125 190 1 1 1 "Alabama" 22126 191 1 1 1 "Alabama" 22127 192 1 1 1 "Alabama" 22128 193 1 1 1 "Alabama" 22129 194 1 1 1 "Alabama" 22130 195 1 1 1 "Alabama" 22131 196 1 1 1 "Alabama" 22132 197 1 1 1 "Alabama" 22133 198 1 1 1 "Alabama" 22134 199 1 1 1 "Alabama" 22135 200 1 1 1 "Alabama" end format %td daily_cases_by_date
So basically all I need to do is create a new variable that counts from the daily_cases_by_date up to the date of the first_public_healthpost to run a Cox-Hazard model of this data. I'm interested in the differences in time to adoption amongst the states.

Comment