data pregnancy_dates; set your_dataset; /* Convert gestational age from weeks to days */ gestation_days = gestational_age * 7; /* Calculate the estimated date of conception */ conception_date = dob - gestation_days; format conception_date dob date9.; run; data pregnancy_days; set pregnancy_dates; /* Initialize the start date */ start_date = conception_date; /* Loop to generate each day in the pregnancy period */ do pregnancy_date = start_date to dob; output; end; format pregnancy_date date9.; run; If you also have a dataset with specific exposure dates, you can compare those dates with the generated pregnancy dates to see if any exposures occurred during the pregnancy: proc sql; create table exposures_during_pregnancy as select a.*, b.exposure_date from pregnancy_days as a left join exposure_data as b on a.pregnancy_date = b.exposure_date where b.exposure_date is not null; quit;
... View more