Randomizing the Order of Questions
Forum rules
New release: CSPro 8.0
New release: CSPro 8.0
-
- Posts: 20
- Joined: August 17th, 2022, 11:07 pm
Randomizing the Order of Questions
Hi CSPro Team and Users,
Is there an option or a way to randomize the order of questions. I want to do it in a system-controlled CAPI. I tried the logic Gregory Martin posted in June 2011 but it is still only for the operator controlled. Is there any option or way to do it now? Thanks
Is there an option or a way to randomize the order of questions. I want to do it in a system-controlled CAPI. I tried the logic Gregory Martin posted in June 2011 but it is still only for the operator controlled. Is there any option or way to do it now? Thanks
Re: Randomizing the Order of Questions
Hi Joshua,
Did you see Greg's later (2018) post about this? Tho in general, this is not something easy to do. And of course you'd have to record what the order of entry is for editing the data later, since you're not allowing the path to run the show, but whatever logic you code. And you'd only want the randomization to occur during initial data entry.
viewtopic.php?f=1&t=2328&p=7689&hilit=r ... rder#p7689
Sherrell
Did you see Greg's later (2018) post about this? Tho in general, this is not something easy to do. And of course you'd have to record what the order of entry is for editing the data later, since you're not allowing the path to run the show, but whatever logic you code. And you'd only want the randomization to occur during initial data entry.
viewtopic.php?f=1&t=2328&p=7689&hilit=r ... rder#p7689
Sherrell
-
- Posts: 20
- Joined: August 17th, 2022, 11:07 pm
Re: Randomizing the Order of Questions
Hi Sherrell,
Yes, I already saw Greg's 2018 post but it can only be useful for repeating questions I think. If there is only a way to use "move" function even though the target field is a skipped field, that will solve our problem.
Also, if you can give me a sample program using what Greg's 2018 post on randomizing the occurrence labels, I will try to use it and replicate it whether it can be another way around for our problem.
Thank you,
Joshua
Yes, I already saw Greg's 2018 post but it can only be useful for repeating questions I think. If there is only a way to use "move" function even though the target field is a skipped field, that will solve our problem.
Also, if you can give me a sample program using what Greg's 2018 post on randomizing the occurrence labels, I will try to use it and replicate it whether it can be another way around for our problem.
Thank you,
Joshua
Re: Randomizing the Order of Questions
Here you go: viewtopic.php?f=1&t=411&p=490&hilit=random#p490
FYI, I found it by using the advanced search, restricting the search to Greg's posts, and restricting it to the "Entry" area looking for a keyword of "random".
FYI, I found it by using the advanced search, restricting the search to Greg's posts, and restricting it to the "Entry" area looking for a keyword of "random".
-
- Posts: 20
- Joined: August 17th, 2022, 11:07 pm
Re: Randomizing the Order of Questions
Hi Sherrell,
Can I ask for your help with my code. How can I make the occurrence labels to be used only once.
Here is my code.
Also, how can I track or save my data file the randomized order so that I can reconstruct it following data entry.
Can I ask for your help with my code. How can I make the occurrence labels to be used only once.
Here is my code.
Code: Select all
PROC Q07000
preproc
array alpha labels(5) = "Coyote", "Wolf", "Fox", "Dhole", "Dog";
do numeric i = 1 while i <= maxocc(Q07000)
numeric label = random(1, 5);
setocclabel(Q07000(i), labels(label));
enddo;
Re: Randomizing the Order of Questions
Hi Joshua,
You need to bring over all the logic from the example, that's why you're getting repeats. Also, as mentioned in the Jan 2018 post from Greg and as I mentioned above, you have to keep track of your randomization by serializing it to your datafile.
That said, I should have mentioned the use of the valueset object randomize function, which has been added since the logic above was written. Here's one way to get what you want. To do this I created a variable in the dictionary, Q07000_TRACK, which has 5 occurrences. It has two subitems, Q07000_label (alpha of length 10) and Q07000_value (numeric length 1).
Sherrell
You need to bring over all the logic from the example, that's why you're getting repeats. Also, as mentioned in the Jan 2018 post from Greg and as I mentioned above, you have to keep track of your randomization by serializing it to your datafile.
That said, I should have mentioned the use of the valueset object randomize function, which has been added since the logic above was written. Here's one way to get what you want. To do this I created a variable in the dictionary, Q07000_TRACK, which has 5 occurrences. It has two subitems, Q07000_label (alpha of length 10) and Q07000_value (numeric length 1).
Code: Select all
PROC GLOBAL
valueset labels;
numeric maxLabels=5;
PROC MYSURVEY_FF
preproc
labels.add("Coyote",1);
labels.add("Wolf", 2);
labels.add("Fox", 3);
labels.add("Dhole", 4);
labels.add("Dog", 5);
PROC Q07000
preproc
valueset current_Q;
if Q07000_label(1)="" then // new entry, initialize the valueset
current_Q = labels;
seed(systime());
current_Q.randomize();
setvalueset ($, current_Q);
do numeric i=1 while i <= maxLabels
Q07000_label(i) = current_Q.labels(i);
Q07000_value(i) = current_Q.codes(i);
enddo;
else // revisiting, display the valueset used before
do numeric i=1 while i <= maxLabels
current_Q.add (Q07000_label(i), Q07000_value(i));
enddo;
setvalueset ($, current_Q);
endif;
-
- Posts: 20
- Joined: August 17th, 2022, 11:07 pm
Re: Randomizing the Order of Questions
Thank you Sherrell.
-
- Posts: 20
- Joined: August 17th, 2022, 11:07 pm
Re: Randomizing the Order of Questions
Hi Sherrell,
I tried to use your codes but I can't seem to replicate it, so I just retained my code and add the do loop to check if the label had already been used. I use the getocclabel() to know what occlabel is I am now and pre-assigned the value to the appropriate question item.
For example; I also used visualvalue(Item) so that even when the interviewer returned to the random question again, the answers to the first random sequence will not be changed. Here is my program, can you check if my codes are correct and if there might be a problem later on.
Thank you very much,
Joshua
I tried to use your codes but I can't seem to replicate it, so I just retained my code and add the do loop to check if the label had already been used. I use the getocclabel() to know what occlabel is I am now and pre-assigned the value to the appropriate question item.
For example; I also used visualvalue(Item) so that even when the interviewer returned to the random question again, the answers to the first random sequence will not be changed. Here is my program, can you check if my codes are correct and if there might be a problem later on.
Thank you very much,
Joshua
Re: Randomizing the Order of Questions
Hi Joshua,
We are a very small shop here and don't have the resources to verify our users' programs. I encourage you to do thorough testing and review of your input and output files to ensure things are working as you want.
Thanks,
Sherrell
We are a very small shop here and don't have the resources to verify our users' programs. I encourage you to do thorough testing and review of your input and output files to ensure things are working as you want.
Thanks,
Sherrell
-
- Posts: 20
- Joined: August 17th, 2022, 11:07 pm
Re: Randomizing the Order of Questions
Okay Sherrell,
Thank you for your help and suggestions.
Last question. If I use seed(INTNO), will I get the same random sequence every time I will run it with the specific interview number?
for example: Interview No: 1
seed(INTNO);
//random sequence......
Thank you,
Joshua
Thank you for your help and suggestions.
Last question. If I use seed(INTNO), will I get the same random sequence every time I will run it with the specific interview number?
for example: Interview No: 1
seed(INTNO);
//random sequence......
Thank you,
Joshua