Hello, everyone! For a project, we have to assess the mean exposure of animals (mice) to PM25. We have been given two data sets, air (with variables DATE (each day from Jan 1 2008 to Dec 31 2011 in date format), PM25 (PM25 levels for each day), and I created variable Average, for the mean exposure to PM25 on a specific day, e.g., the average exposure to PM25 on the second line of obs is PM25 on day 1 plus PM25 on day 2 divided by 2, etc.). An example of the data is given below: Obs date PM25 average 1 01JAN2008 10.9167 10.9167 2 02JAN2008 10.9167 10.9167 3 03JAN2008 17.6250 13.1528 4 04JAN2008 31.0833 17.6354 5 05JAN2008 5.0833 15.1250 6 06JAN2008 4.1667 13.2986 7 07JAN2008 2.8333 11.8036 8 08JAN2008 2.8750 10.6875 9 09JAN2008 13.5833 11.0093 10 10JAN2008 14.7500 11.3833 11 11JAN2008 . 11.3833 12 12JAN2008 . 11.3833 13 13JAN2008 . 11.3833 14 14JAN2008 . 11.3833 15 15JAN2008 . 11.3833 16 16JAN2008 . 11.3833 17 17JAN2008 . 11.3833 18 18JAN2008 . 11.3833 19 19JAN2008 . 11.3833 20 20JAN2008 . 11.3833 21 21JAN2008 . 11.3833 22 22JAN2008 12.7000 11.5030 23 23JAN2008 0.8182 10.6126 We also have data set ANIMAL, which includes the birthdate and date of assessment of a biomarker. An example is given below: birth_ Obs ID date pft_date biomarker 1 38886 01APR2008 07OCT2011 279.36 2 38949 08APR2008 20JUL2011 304.67 3 38957 09APR2008 19AUG2011 280.78 4 38958 09APR2008 01SEP2011 259.08 5 38973 10APR2008 19SEP2011 229.85 6 38981 11APR2008 15AUG2011 355.20 7 38989 12APR2008 12AUG2011 274.00 8 38993 12APR2008 14OCT2011 353.24 9 38994 12APR2008 11OCT2011 262.81 10 39000 13APR2008 25JUL2011 240.00 We need to assess the mean exposure to PM25 (from birth to date of biomarker assessment) for each mouse. I tried to go about connecting the two data sets by creating macro variables for date and Average PM25 from data set AIR, but I'm having trouble then using these macro variables (in an array I was thinking) in data set ANIMAL. I have never used code like this before so I'm clearly misunderstanding how macro variables created outside a data step can be used. Here is what I tried: /*Create macro variables for Measurement Date and Average PM25*/ data _null_; set air; suffix=put(_n_, 10.); call symput(cats('ExpDt',suffix), (put(date, mmddyy10.))); call symput(cats('AvPM25', suffix), average); run; %put &ExpDt1 &AvPM251; data test; set animal; &array ExpDt(*) &ExpDt.: ; &array AvPM25(*) &AvPM25.: ; &do i=1 to &Dim(&ExpDt.); &if &ExpDt. EQ birth_date &then Exp1=&AvPM25.; &if &ExpDt. EQ pft_date &then Exp2=&AvPM25.; &end; AvgPM25Exp=(Exp2-Exp1); run; Any help would be greatly appreciated. Thank you!
... View more