Random Next-Birthday Respondent Selection

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Random Next-Birthday Respondent Selection

Post by Gregory Martin »

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.
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));
Attachments
randomBirthday.zip
(2.86 KiB) Downloaded 570 times
Post Reply