Hello, i would like to calculate a mean of the variable exposure for each woman during a whole pregnancy, here between 2 dates (Dateconception and Datebirth). The exposure measurement corresponds to the value measured on the day of Datebirth. The data is centered around Datebirth, so i presume i would need to transform to long format with events conception & birth with the daily values of exposure.
Could anyone help me figure this out? i have pasted a dataex sample of the main variables child ID exposure level date of conception and date of birth.
thank you
Sincerely
Mathieu



Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input str5 ID double Exposure float(Datebirth Dateconception)
"62316"    8 22281 22008
"62317"    8 22281 22015
"62318"    8 22281 22015
"62321"    8 22281 22008
"62327"    8 22281 22015
"62326"    8 22281 22008
"62328"    8 22281 22113
"62329"    8 22281 22022
"62334"  8.6 22282 22016
"62340"  8.6 22282 22009
"62344"  8.6 22282 22009
"62346"  8.6 22282 22009
"62349" 10.6 22283 22024
"62348" 10.6 22283 21989
"62573" 10.6 22283 22010
"62352" 10.6 22283 22010
"62369" 10.6 22283 22017
"62371" 10.6 22283 21996
"62381" 13.3 22284 22004
"62392" 13.3 22284 22102
"62395" 13.3 22284 22018
"62393" 13.3 22284 21997
"62405"  8.3 22285 22026
"62412"  8.3 22285 22012
"62414" 17.1 22286 22013
"62421" 17.1 22286 22076
"62420" 17.1 22286 22020
"62427" 17.1 22286 22055
"62429" 17.1 22286 22006
"62433"  8.8 22287 22014
end
format %td Datebirth
format %td Dateconception