Selecting a random household member for interview

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
Yass
Posts: 103
Joined: November 11th, 2017, 1:26 am

Selecting a random household member for interview

Post 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.
aaronw
Posts: 561
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: Selecting a random household member for interview

Post 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
Post Reply