Randomizing the Order of Questions

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
joshua.deguito
Posts: 20
Joined: August 17th, 2022, 11:07 pm

Randomizing the Order of Questions

Post by joshua.deguito »

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
sherrell
Posts: 397
Joined: April 2nd, 2014, 9:16 pm
Location: Washington, DC

Re: Randomizing the Order of Questions

Post by sherrell »

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
joshua.deguito
Posts: 20
Joined: August 17th, 2022, 11:07 pm

Re: Randomizing the Order of Questions

Post by joshua.deguito »

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
sherrell
Posts: 397
Joined: April 2nd, 2014, 9:16 pm
Location: Washington, DC

Re: Randomizing the Order of Questions

Post by sherrell »

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".
joshua.deguito
Posts: 20
Joined: August 17th, 2022, 11:07 pm

Re: Randomizing the Order of Questions

Post by joshua.deguito »

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.

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;
Also, how can I track or save my data file the randomized order so that I can reconstruct it following data entry.
sherrell
Posts: 397
Joined: April 2nd, 2014, 9:16 pm
Location: Washington, DC

Re: Randomizing the Order of Questions

Post by sherrell »

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).

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;
Sherrell
joshua.deguito
Posts: 20
Joined: August 17th, 2022, 11:07 pm

Re: Randomizing the Order of Questions

Post by joshua.deguito »

Thank you Sherrell.
joshua.deguito
Posts: 20
Joined: August 17th, 2022, 11:07 pm

Re: Randomizing the Order of Questions

Post by joshua.deguito »

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;
RandomQuestion.JPG
RandomQuestion.JPG (37.82 KiB) Viewed 1554 times
RandomQuestion1.JPG
RandomQuestion1.JPG (38.5 KiB) Viewed 1553 times
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.
RandomQuestion.zip
(3.53 KiB) Downloaded 77 times
Thank you very much,
Joshua
sherrell
Posts: 397
Joined: April 2nd, 2014, 9:16 pm
Location: Washington, DC

Re: Randomizing the Order of Questions

Post by sherrell »

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
joshua.deguito
Posts: 20
Joined: August 17th, 2022, 11:07 pm

Re: Randomizing the Order of Questions

Post by joshua.deguito »

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
Post Reply