Random occurrence generation in a List

Discussions about CSEntry
Post Reply
sergiofurtado
Posts: 25
Joined: October 5th, 2019, 1:43 pm

Random occurrence generation in a List

Post by sergiofurtado » October 21st, 2019, 9:39 am

Hi all,

I have a problem and would like your opinion:

I have a questionnaire with two sections: household characteristics and information from each resident.

Some sections contain information for all residents while others should be directed to residents drawn for particular age groups.

For example, suppose we have 14 residents in a household, distributed as follows:

Age group | Number of Residents
0 - 5 years | 2
6 - 15 years | 3
16 - 35 years | 4
36 - 60 years | 3
Over 60 | 2

From certain sections of the questionnaire, we would have to draw only one resident from each age group and this group of drawn residents would be persistent for all other sections.

At first, I thought of using the random function, but by default, the sequence of random numbers generated by repeated calls to random will always be the same.

What alternative would you have to solve this problem?

Note: if possible, could you indicate the respective codes to solve the problem?

Thanks in advance,

josh
Posts: 1988
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Random occurrence generation in a List

Post by josh » October 21st, 2019, 11:04 am

Use the seed function with the current time so that random function will return a different sequence of results each time.

See this similar post: viewtopic.php?f=1&t=2616&p=8646

sergiofurtado
Posts: 25
Joined: October 5th, 2019, 1:43 pm

Re: Random occurrence generation in a List

Post by sergiofurtado » October 21st, 2019, 11:34 am

Hi Josh!

Many thanks once again for the information and speed in answering the questions.

Post Reply