Dear Sir,
How to automatically select 5% people in a roster (randomly) and people name should be shown in a dialog box.
Thanks
Manoj
How to select 5% people in a roster (randomly)
-
- Posts: 1796
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: How to select 5% people in a roster (randomly)
I would suggest maintaining an array (or using a repeating item in the working storage dictionary) to maintain a flag of whether or not you have sampled a given occurrence.
Then loop through the people in your roster, and write something like this:
Then loop through the people in your roster, and write something like this:
numeric number_to_select = {fill this in somehow, making it a whole number};
numeric number_selected = 0;
numeric occurrence_number;
while number_selected < number_to_select do
do occurrence_number = 1 while number_selected < number_to_select and occurrence_number <= totocc(PERSON)
if random(1,100) <= 5 then
FLAG(occurrence_number) = 1;
inc(number_selected);
endif;
enddo;
enddo;
After this loop runs, you have your 5% sample (where FLAG = 1), and you can add these people to a roster of selected persons.numeric number_selected = 0;
numeric occurrence_number;
while number_selected < number_to_select do
do occurrence_number = 1 while number_selected < number_to_select and occurrence_number <= totocc(PERSON)
if random(1,100) <= 5 then
FLAG(occurrence_number) = 1;
inc(number_selected);
endif;
enddo;
enddo;