Multiple choice question

Discussions about CSEntry
linh11111
Posts: 5
Joined: March 22nd, 2013, 3:00 am

Multiple choice question

Post by linh11111 »

Dear Forum,

I have a question,

How to do with multiple choices questions with the answer choices are not follow the order. Eg.
Question. C2a. What are the benefits of colostrums?
1. Protect againts infection
2. Clear meconium
3. Helps to prevent jaundice
4. Helps the intestine to mature
8. Do not know
9. Other
Because when I use occu=6 then I have 6 vars Entry(1), Entry(2)…Entry(6), so I have to enter from 1 until 6, can not follow the questionnaire 1,2,3,4,8,9.
PROC C2A
PostProc
if ($ in 1:6) then
if c2a_entry($) = "1" then
c2a_entry($) = " ";
if $=6 then
c2a99="";
endif;
else
c2a_entry($) = "1";
endif;
reenter;
elseif $ = 0 then

numeric ctr;

do ctr = 1 while (ctr in 1:6)
if c2a_entry(ctr) = " " then
c2a_entry(ctr) = "0";
endif;
enddo;

skip to c2a99;

endif;
Is there any way to help me follow the code of the questionnaire from 1-4, 8, 9 in charge of 1-6.

Thanks
Linh
Adnane
Posts: 30
Joined: November 22nd, 2012, 4:45 am

Re: Multiple choice question

Post by Adnane »

Here is an example where you can learn from it.
Attachments
Multi_quest_exp.rar
(31.58 KiB) Downloaded 1860 times
Gregory Martin
Posts: 1845
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Multiple choice question

Post by Gregory Martin »

Linh,

Does it work you to use a checkbox field for the question (the suggestion that Adnane sent)? If so, make C2A an alpha field of length six. Then it can store all of the options for that question. Add each of the options to your value set, and then set the data capture type for the field to be a checkbox.

The problem with this approach is that, unless the operator uses the mouse to answer the question, the operator can enter invalid codes to the field (because it is an alpha field). You can get around this by adding logic to the field's postproc to check that every character of the alpha field is in 1 to 4, 8, 9, and a space. You can use the poschar function to do this.
linh11111
Posts: 5
Joined: March 22nd, 2013, 3:00 am

Re: Multiple choice question

Post by linh11111 »

Dear Martin,

Thanks for your help, but I still have some confuse on this. I copy my command here. Now I can enter 1 to 4, 8,9 for multiple question, but I still do not know how to clear the entered choice for multiple choices question. Can you help me on this?

Thanks so much,

Linh

PROC C2A
postproc
if (c2a in 0,1,2,3,4,8,9) then
if c2a=1 then
c2a_entry(1)="1";
endif;
if c2a=2 then
c2a_entry(2)="1";
endif;
if c2a=3 then
c2a_entry(3)="1";
endif;
if c2a=4 then
c2a_entry(4)="1";
endif;
if c2a=9 then
c2a_entry(5)="1";
endif;
if c2a=8 then
c2a_entry(6)="1";
endif;
if c2a=0 then
c2a_entry($)="";
endif;
reenter;
if c2a=0 & c2a_entry(5)="1" then
skip to c3;
endif;
endif;
linh11111
Posts: 5
Joined: March 22nd, 2013, 3:00 am

Re: Multiple choice question

Post by linh11111 »

Adnane wrote:Here is an example where you can learn from it.
Thanks Adnane,

For your example, I think it is good for me to learn, but one thing I do not understand that why in dictionary you just write maternal is alpha item with len 5 and did not has got any occ but why when you generate the form you have master field maternal with 5 occ.

Can you explain for me,

Thank you so much,

Linh
Adnane
Posts: 30
Joined: November 22nd, 2012, 4:45 am

Re: Multiple choice question

Post by Adnane »

Effectively, in reality I also do not see that, in fact there are several ways to make a "multiple response",
I invite you to consult directly the conversation where I have got this example (this is an example posted by "marialange"), you can also find another example, here is the conversation:

http://csprousers.org/forum/viewtopic.p ... check#p623

see another exemple attached.
Attachments
breastfeedingBenefits.zip
(3.25 KiB) Downloaded 1094 times
Guest

Re: Multiple choice question

Post by Guest »

Gregory Martin wrote:Linh,

Does it work you to use a checkbox field for the question (the suggestion that Adnane sent)? If so, make C2A an alpha field of length six. Then it can store all of the options for that question. Add each of the options to your value set, and then set the data capture type for the field to be a checkbox.

The problem with this approach is that, unless the operator uses the mouse to answer the question, the operator can enter invalid codes to the field (because it is an alpha field). You can get around this by adding logic to the field's postproc to check that every character of the alpha field is in 1 to 4, 8, 9, and a space. You can use the poschar function to do this.

Hi Martin,

I applied all of your guides, but I do not know why in example Adnane sent to me, Maternal field is an alpha with 4 length, and 1 occ, but in the form Maternal can become roster field with 4 occ and she can wrote logic check for that field.

PROC MATERNAL000


onfocus
maternal_lin(1)=0;
maternal_lin(2)=0;
maternal_lin(3)=0;
maternal_lin(4)=0;
maternal_lin(5)=0;

killfocus
i=1;
WHILE i <= 5 DO
IF maternal[i:1] in "1" THEN maternal_lin(1)=1;
ELSEIF maternal[i:1] in "2" THEN maternal_lin(2)=2;
ELSEIF maternal[i:1] in "3" THEN maternal_lin(3)=3;
ELSEIF maternal[i:1] in "4" THEN maternal_lin(4)=4;
ELSEIF maternal[i:1] in "5" THEN maternal_lin(5)=5;
endif;
i = i + 1;
ENDDO;
DELAY=maternal_lin(1);
GOOD=maternal_lin(2);
STIMULATE=maternal_lin(3);
INCREASE=maternal_lin(4);
ECONOMIC=maternal_lin(5);


Can you help me,

Thanks,

Linh
Gregory Martin
Posts: 1845
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Multiple choice question

Post by Gregory Martin »

The breastfeeding example is demonstrating two different ways to enter multiple values. BENEFITS_CHECKBOX is an alpha of length 5 that utilizes CSPro's popup checkbox feature. BENEFITS_REPEATING_ITEM is a numeric of length 1 that repeats 5 times, forcing the keyer the enter values for all five options, not just the ones that were selected during the interview.

If you want further help, it would be better to post your code on this site. Zip your application and you can attach it to a post. It is very difficult to figure out the problem by only looking at the code. We need to see the dictionary as well.
kdar
Posts: 2
Joined: April 3rd, 2014, 4:54 am

Re: Multiple choice question

Post by kdar »

Hi All,

Many thanks for logic for multiple choice questions. I have applied this logic in roster multiple choice questions it has been worked only for single numeric response from 1 to 9 but it has not worked at all when response digit double. e.g. how to write logic or manipulate on the existing following logic to enter after 9 number. When I enter 96 for others response it store in two different sub items one is on 6 place other one is on 96 place. In the same way if i enter 10 then its only enter 1, 11 only enter 1, 12 enter in 1 and 2 instead of store in 12 sub items and so on. I have attached logic prepared based on the following logic. In general, how to write logic for double number response e.g.10, 11, and so on. Please suggest and check my file.

regards,
kdar
Guest wrote:
Gregory Martin wrote:Linh,

Does it work you to use a checkbox field for the question (the suggestion that Adnane sent)? If so, make C2A an alpha field of length six. Then it can store all of the options for that question. Add each of the options to your value set, and then set the data capture type for the field to be a checkbox.

The problem with this approach is that, unless the operator uses the mouse to answer the question, the operator can enter invalid codes to the field (because it is an alpha field). You can get around this by adding logic to the field's postproc to check that every character of the alpha field is in 1 to 4, 8, 9, and a space. You can use the poschar function to do this.

Hi Martin,

I applied all of your guides, but I do not know why in example Adnane sent to me, Maternal field is an alpha with 4 length, and 1 occ, but in the form Maternal can become roster field with 4 occ and she can wrote logic check for that field.

PROC MATERNAL000


onfocus
maternal_lin(1)=0;
maternal_lin(2)=0;
maternal_lin(3)=0;
maternal_lin(4)=0;
maternal_lin(5)=0;

killfocus
i=1;
WHILE i <= 5 DO
IF maternal[i:1] in "1" THEN maternal_lin(1)=1;
ELSEIF maternal[i:1] in "2" THEN maternal_lin(2)=2;
ELSEIF maternal[i:1] in "3" THEN maternal_lin(3)=3;
ELSEIF maternal[i:1] in "4" THEN maternal_lin(4)=4;
ELSEIF maternal[i:1] in "5" THEN maternal_lin(5)=5;
endif;
i = i + 1;
ENDDO;
DELAY=maternal_lin(1);
GOOD=maternal_lin(2);
STIMULATE=maternal_lin(3);
INCREASE=maternal_lin(4);
ECONOMIC=maternal_lin(5);


Can you help me,

Thanks,

Linh
Attachments
test1 (2).zip
(5.03 KiB) Downloaded 775 times
Gregory Martin
Posts: 1845
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Multiple choice question

Post by Gregory Martin »

You can get this to work. I suggest that you make each of your choices two digits, so 01, 02, 03, ..., 96. I also had to fix your subitem starting positions, as you had overlapping subitems. See the attached file.
Attachments
RISMFP.7z
(1.98 KiB) Downloaded 970 times
Post Reply