How to creat logic files for a multiple question

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Dung Le

How to creat logic files for a multiple question

Post by Dung Le »

Hi all,

I have a programing and i am really confused how to create a logic file for it. I hope someone can help me to address it. In fact, i got problem with how to create a logic command for a multiple choice question. For example:

Can you tell me benefits of breastfeeding for mother?

1) Delay pregnancy
2) Good for mother's health (reduce risk of breast cancer)
3) Stimulate breast milk production
4) Increase link between mother and child
5) Economic benefit.

For epidata software, it is very simple for me, but this is the first time i have used CSpro so please direct me more detail.

Thanks so much.
marialange
Posts: 20
Joined: December 12th, 2011, 12:00 pm

Re: How to creat logic files for a multiple question

Post by marialange »

I think you should create a variable (Item) 1 long alphanumeric. Occurrence and 5 in the data dictionary and give each value you mention.
Then you use in your program as multiple loading
saobachminh
Posts: 16
Joined: March 19th, 2012, 11:14 am

Re: How to creat logic files for a multiple question

Post by saobachminh »

marialange wrote:I think you should create a variable (Item) 1 long alphanumeric. Occurrence and 5 in the data dictionary and give each value you mention.
Then you use in your program as multiple loading
I understand what you mean and i did it, the form is okie for me. My point is how to write logic files for it, i did some but it does not work. Cloud you (anyone) please write a logic file for me as an example by using my example?

Thanks a lot.
marialange
Posts: 20
Joined: December 12th, 2011, 12:00 pm

Re: How to creat logic files for a multiple question

Post by marialange »

You can check the CSPro Help, looking for Check Box
lls
Posts: 109
Joined: December 6th, 2011, 3:11 pm
Location: Geneva, Switzerland

Re: How to creat logic files for a multiple question

Post by lls »

Check boxes are alphanumeric and alphanumeric can not be tabulated.

Check boxes are good if you export your data in a other statistical software such as SPSS

If you need to use CSPro for tabulation, it is better to avoid alphanumeric fields
saobachminh
Posts: 16
Joined: March 19th, 2012, 11:14 am

Re: How to creat logic files for a multiple question

Post by saobachminh »

lls wrote:Check boxes are alphanumeric and alphanumeric can not be tabulated.

Check boxes are good if you export your data in a other statistical software such as SPSS

If you need to use CSPro for tabulation, it is better to avoid alphanumeric fields

I tried to do like this but it did not work, could you (anybody) check it out and correct it for me?


PROC BENEFIT_ENTRY { mother benefit, driver variable }
{ This variable toggles occurrences of the BENEFIT variable }
PostProc
if $ in 1:5 then
if BENEFIT($) = "1" then
BENEFIT($) = " ";
else
BENEFIT($) = "1";
endif;
reenter;
endif;
$ = 9;

{ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= }

For benefit (item), its value was set 1 "has" and 0 'dose not has"
benefit_entry was added the value that i mentioned on example above (including 0"finished")

Thanks all.
marialange
Posts: 20
Joined: December 12th, 2011, 12:00 pm

Re: How to creat logic files for a multiple question

Post by marialange »

Well, I think the multiple alphanumeric variable step but then the numeric fields (for my tabulated). For example:
Alphanumeric variable: maternal length of 1 to 5 occurrences
Then numerical variable: Delay for -> 1) Delay pregnancy
Another numeric variable Good for -> 2) Good for mother's health (reduces Risk of breast cancer) and so the rest ....
The program captures the variable alphanumeric receipt and the logical step program as numerical variables as follows:

MATERNAL
preproc
{Variables are initialized}
NumReturnFunctionValue = maternal_lin (5); _____>This part calls a function to initialize the variables, and maternal_lin is a vector
postproc
{IDENTIFICATION AND TEMPORARY STORAGE OPTIONS IN VARIABLES RESPECTIVE ANSWERS TO MULTIPLE}
Do varying i = 1 until i> 5 by 1;
IF $ in "1" THEN maternal_lin (1) = 1;
ELSEIF $ [i: 1] in "2" THEN maternal_lin (2) = 2;
ELSEIF $ [i: 1] in "3" THEN maternal_lin (3) = 3;
ELSEIF $ [i: 1] in "4" THEN maternal_lin (4) = 4;
ELSEIF $ [i: 1] in "5" THEN maternal_lin (5) = 5;
ENDIF;
ENDDO;
{ASSIGNED VALUES IN SELECTED IN ITS MULTIPLE VARIABLE}
Delay = maternal_lin (1);
Good = maternal_lin (2);
...........
This way you can capture in a variable and then chek box can be processed in alphanumeric variables.
I hope you serve..
saobachminh
Posts: 16
Joined: March 19th, 2012, 11:14 am

Re: How to creat logic files for a multiple question

Post by saobachminh »

Thanks for your great help, Marialange

I tried to use your logic step program but something was wrong. For more detail, when i finished logic step and started compiling, compiler output showed like this:

ERROR: 'ReturnFunctionValue' is not a declared variable or is a misspelled dictionary entry
ERROR: You must assign the result of the function to an alpha near line 3 in MATERNAL_ENTRY procedure

I do not know how to fix it, could you please help me to fix it again.

Thank you so much.
marialange
Posts: 20
Joined: December 12th, 2011, 12:00 pm

Re: How to creat logic files for a multiple question

Post by marialange »

you can leave out the initialization of variable as a function and initialize it before deploying the field
but you must declare the variable in the section maternal_lin
PROC GLOBAL
Maternal_lin ARRAY (5);
saobachminh
Posts: 16
Joined: March 19th, 2012, 11:14 am

Re: How to creat logic files for a multiple question

Post by saobachminh »

Dear Marialange,

Did you try to work it on CSpro? Or your logic step program is just in your mind and then you wrote it down? I tried it but it did not work. Could you please send an attach file that you did to me? I am a new user so everything seems confused for me. Thank you a lot and sorry if it makes any inconveniences for you.

Best,
Post Reply