Page 1 of 1

Selecting a random household member for interview

Posted: May 29th, 2019, 7:56 am
by Yass
Hi Cspro
I was trying to use the random function to select a member of household for an individual questionnaire (app) which is different from the household.

Thus i will like to randomly select the member age 16 above in a roster into a dummy field then write that file as a lookup. i got stuck because i could not specify the start and end of the random number. It more complex than i thought. Need assistance.

Re: Selecting a random household member for interview

Posted: May 31st, 2019, 5:17 pm
by aaronw
I'll assume your household members are stored in a roster like this:

Code: Select all

Annie 55
Teddy 10
Kenny 37
Susie 27
Use count to get the total number of household members greater than or equal to 16. In our case that is 3. Now we can call:
i = random(1,3);
Let's say this returns 2. Use seek to find the 2nd occurrence of household members greater than equal to 16. This will return 3 which is Kenny's occurrence.

count: http://www.csprousers.org/help/CSPro/co ... ction.html
seek: http://www.csprousers.org/help/CSPro/seek_function.html