Random occurrence generation in a List

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
sergiofurtado
Posts: 29
Joined: October 5th, 2019, 1:43 pm

Random occurrence generation in a List

Post by sergiofurtado »

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: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Random occurrence generation in a List

Post by josh »

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: 29
Joined: October 5th, 2019, 1:43 pm

Re: Random occurrence generation in a List

Post by sergiofurtado »

Hi Josh!

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