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.
Selecting a random household member for interview
Forum rules
New release: CSPro 8.0
New release: CSPro 8.0
Re: Selecting a random household member for interview
I'll assume your household members are stored in a roster like this:
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:
count: http://www.csprousers.org/help/CSPro/co ... ction.html
seek: http://www.csprousers.org/help/CSPro/seek_function.html
Code: Select all
Annie 55
Teddy 10
Kenny 37
Susie 27
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