Automatically make the system to preselect the 1st options that appear in setvalueset

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
sham
Posts: 69
Joined: February 3rd, 2022, 7:30 pm

Automatically make the system to preselect the 1st options that appear in setvalueset

Post by sham »

Hi family,
I have a challenge here.
I created a setvalueset from the a roster using preproc. Is there a way to allow the system to select the 1st option that appear in the setvalueset RESULTS regardless about the value serial numbering?

for example
Below is the logic I used to pull out the list of eligible person's in the household age 15-49years at random
PROC ID_FROM_THE_ROSTER
preproc
do numeric i = 1 while i <= totocc(ROSTER000)
if AGE(i) in 15:149 then
RosterRespondent.add(NAME(i),i);
endif;
enddo;
seed(systime());
RosterRespondent.randomize();
setvalueset($,RosterRespondent);
the results I got is;
option1 3. Child1
option2 5. Child
option1 7. Child5

Can any one assist me with a logic to make the program automatically select the the 1st position(child3) from the setvalueset results above?

Thank you
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Automatically make the system to preselect the 1st options that appear in setvalueset

Post by Gregory Martin »

You can access the codes and labels as lists:

https://www.csprousers.org/help/CSPro/valueset.html

So this would give you the first code (if one has been defined):
RosterRespondent.codes(1)
sherrell
Posts: 397
Joined: April 2nd, 2014, 9:16 pm
Location: Washington, DC

Re: Automatically make the system to preselect the 1st options that appear in setvalueset

Post by sherrell »

Sham, I hope you've noticed the typo in your logic. You wrote the following comment:

>Below is the logic I used to pull out the list of eligible person's in the household age 15-49years at random

Yet your logic is checking to 149 years:

>if AGE(i) in 15:149 then

Sherrell
sham
Posts: 69
Joined: February 3rd, 2022, 7:30 pm

Re: Automatically make the system to preselect the 1st options that appear in setvalueset

Post by sham »

Hi,
@Sherrell you got it right it is indeed a typo from me. I actually mean 15-49.
@ Gregory Martin thank you very much for the guide.

It is working soo well.

I Am grateful.
Post Reply