200 likes | 426 Views
Hidden Biases Using SAS Dates. Steve James. Information Specialist GASUG Meeting February 1, 2012. National Center for Immunization & Respiratory Diseases. Informatics Office. Hidden Biases Using SAS Dates Summary.
E N D
Hidden Biases Using SAS Dates Steve James Information Specialist GASUG MeetingFebruary 1, 2012 National Center for Immunization & Respiratory Diseases Informatics Office
Hidden Biases Using SAS DatesSummary • Just because SAS stores its dates as numbers doesn’t solve all of your problems with dates. • There can be a hidden bias with dates when using units such as months and years. • How you calculate age can introduce a bias.
Hidden Biases Using SAS DatesIntroduction • CDC is developing a system to analyze patient-level Immunization data collected by State Health Departments. • Whether a dose of a vaccine is valid is a critical piece of information for analyzing the data. • A key component of dose validation is the age a patient receives a vaccination.
Hidden Biases Using SAS DatesIntroduction • The Advisory Committee for Immunization Practices (ACIP) determines the guidelines for minimum age of each vaccine. • For example, the minimum age for the Influenza (Flu) vaccine is 6 months. • There is a 4-day grace period associated with all minimum age and minimum intervals.
Initial Design Discussions • How many days are in a year? • “SAS knows how to handle dates.”
SAS Pseudo-Code • Minimum Age for Influenza (Flu) Vaccine is 6 months • IF VaccinationDate – DOB ge 6 months then valid = 1 ; else valid = 0 ;
How Many Days Are In 6 Months? • 180? • 181? • 184? • It depends?
It Depends? • January 1 to July 1 2012 has 182 days. • March 1 to September 1, 2012 has 184. • June 1 to December 1, 2012 has 183. • September 1, 2012 to March 1 2013 has 181.
Hockey and Birthdate Bias • Malcolm Gladwell in his book Outliers describes how some elite Canadian hockey teams have a disproportionate number of players born in the first half of the year. • How children were selected for youth hockey introduced a bias. • Children born soon after the cutoff date had an advantage over those born later in the year.
Problem • There’s not a foolproof way to convert months and years into a certain number of days. • Any attempt to try to force it will cause some doses to be valid when they shouldn’t be and some not to be valid when they should be. • This is a bias that might be easily overlooked in testing.
How Do We Solve This? • MinAgeUnit=‘Months’ ; • MinAgeValue=6 ;If MinAgeUnit = ‘Months’ then do ; if AgeInMonths< MinAgeValue then Valid = ‘No’ ; else Valid = ‘Yes’ ;
Brute Force If MinAgeUnit = ‘Years’ then do ; if AgeInYears < MinAgeValue then Valid = ‘No’ ; else Valid = ‘Yes’ ;If MinAgeUnit = ‘Weeks’ then do ; if AgeInWeeks< MinAgeValue then Valid = ‘No’ ; else Valid = ‘Yes’ ;If MinAgeUnit = ‘Days’ then do ; if AgeInDays< MinAgeValue then Valid = ‘No’ ; else Valid = ‘Yes’ ;
Using Arrays • Array Ages(*) AgeInYearsAgeInMonthsAgeInWeeksAgeInDays;if MinAgeUnit=‘Years’ then index=1;else if MinAgeUnit=‘Months’ then index=2 ;else if MinAgeUnit=‘Weeks’ then index=3 ;else if MinAgeUnit=‘Days then index=4 ;if Ages(index) < MinAgeValue then valid=‘No’ ; else valid=‘Yes’ ;
Calculate Date Minimum Age is Reached • MinAgeDate = INTNX(MinAgeUnit, DOB, MinAgeValue,‘sameday’) - GracePeriod ;If VaccinationDate < MinAgeDate then valid = ‘No’ ; else valid = ‘Yes’ ;
INTNX Function • Returns a SAS date value incremented by a specific number of intervals. • SAMEDAY option available in SAS 9 preserves the alignment of the date within the interval before its incremented.
Calculating Age in Years • Age = INT((SomeDate – DOB) / 365.25 ) ;Off by 1for dates exactly on anniversary. E.G. 01/01/2011 – 01/01/2010 = 365 Int (365/365.25) = 0
Calculating Age in Years • INT (( INTCK(‘month’, DOB,SomeDate) - (DAY(DOB) > DAY(SomeDate))) /12 ) ;This calculates the number of months between two dates and divides that number by 12. • (DAY(DOB) > DAY(SomeDate)) adjusts for those cases when a whole month hasn’t been completed.
Summary • Just because SAS stores its dates as numbers doesn’t solve all of your problems with dates. • There can be a hidden bias with dates when using units such as months and years. • How you calculate age can introduce a bias.
Steve Jamesspj1@cdc.gov404-639-6041 For more information please contact Centers for Disease Control and Prevention 1600 Clifton Road NE, Atlanta, GA 30333 Telephone: 404-639-6041 E-mail: spj1@cdc.gov Web: http://www.cdc.gov The findings and conclusions in this report are those of the authors and do not necessarily represent the official position of the Centers for Disease Control and Prevention. National Center for Immunization & Respiratory Diseases