Hello,
I'm having trouble generating mean variable for cumulative lag periods (2-3 days, 2-4 days, 2-5 days etc.). Below data example shows case (lag days 2 and 3) and control days as well as corresponding SO2 and apparent temp values. I'd like to get mean values for lag days 2 and 3 for SO2 and apparent temp so that each subject has one mean value for case days (lag days 2 and 3) and three mean values for control days (corresponding days of lag days 2 and 3).
I've searched around a lot but haven't really found a solution to it. Maybe my search wording was not good enough. I'd really appreciate it if someone could help me with this.
TIA,
Temuulen
I'm having trouble generating mean variable for cumulative lag periods (2-3 days, 2-4 days, 2-5 days etc.). Below data example shows case (lag days 2 and 3) and control days as well as corresponding SO2 and apparent temp values. I'd like to get mean values for lag days 2 and 3 for SO2 and apparent temp so that each subject has one mean value for case days (lag days 2 and 3) and three mean values for control days (corresponding days of lag days 2 and 3).
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float id double ndate byte case float(so2_pred_ppb apptemp) 13 18282 0 24.16576 -13.62427 13 18283 0 21.32349 -14.36305 13 18289 0 22.08568 -9.079194 13 18290 0 19.47187 -12.661038 13 18296 1 22.098206 -14.340417 13 18297 1 23.73793 -13.093917 13 18303 0 17.472273 -13.639982 13 18304 0 32.25117 -14.520927 14 18284 0 27.81144 -14.220161 14 18285 0 28.787304 -14.06131 14 18291 0 20.79549 -10.927979 14 18292 0 25.071177 -12.635675 14 18298 1 9.025553 -12.27794 14 18299 1 15.59949 -12.816295 14 18305 0 33.91532 -14.02643 14 18306 0 19.734413 -14.194155 end format %td ndate
TIA,
Temuulen
Comment