Random Next-Birthday Respondent Selection
Posted: October 12th, 2011, 12:23 pm
In a country where few people know their birthdays, but where you want to use the next-birthday method of respondent selection, you may consider randomly assigning birthdays to each respondent.
From that point, using the datediff, min, and seek functions, it is easy to randomly choose a respondent to interview. See the attached application for an example.
From that point, using the datediff, min, and seek functions, it is easy to randomly choose a respondent to interview. See the attached application for an example.
PROC GLOBAL
array monthDays(12) = 31 28 31 30 31 30 31 31 30 31 30 31;
numeric itr;
PROC RANDOMBIRTHDAY_FF
preproc
seed(systime());
PROC NAME
numeric month = random(1,12);
numeric day = random(1,monthDays(month));
DAYS_UNTIL_BIRTHDAY = datediff(sysdate("YYYYMMDD"),sysdate("YYYY") * 10000 + month * 100 + day);
skip to next NAME;
PROC RANDOMBIRTHDAY_ID
preproc
numeric leastDays = min(DAYS_UNTIL_BIRTHDAY where DAYS_UNTIL_BIRTHDAY >= 0);
if leastDays = default then // none of the birthdays occur until the next calendar year
leastDays = min(DAYS_UNTIL_BIRTHDAY);
endif;
numeric respondentIndex = seek(DAYS_UNTIL_BIRTHDAY = leastDays);
errmsg("We choose %s",NAME(respondentIndex));
array monthDays(12) = 31 28 31 30 31 30 31 31 30 31 30 31;
numeric itr;
PROC RANDOMBIRTHDAY_FF
preproc
seed(systime());
PROC NAME
numeric month = random(1,12);
numeric day = random(1,monthDays(month));
DAYS_UNTIL_BIRTHDAY = datediff(sysdate("YYYYMMDD"),sysdate("YYYY") * 10000 + month * 100 + day);
skip to next NAME;
PROC RANDOMBIRTHDAY_ID
preproc
numeric leastDays = min(DAYS_UNTIL_BIRTHDAY where DAYS_UNTIL_BIRTHDAY >= 0);
if leastDays = default then // none of the birthdays occur until the next calendar year
leastDays = min(DAYS_UNTIL_BIRTHDAY);
endif;
numeric respondentIndex = seek(DAYS_UNTIL_BIRTHDAY = leastDays);
errmsg("We choose %s",NAME(respondentIndex));