Answering Calculations

Other discussions about CSPro
MrTaco
Posts: 128
Joined: November 18th, 2014, 1:55 am

Answering Calculations

Post by MrTaco »

Hey Guys

I want to add two answers into one Question, so i wouldn't have to answer on the third quetion

This the scenario: Q1) Answer is 1
Q2) Answer is 1
then I want on the third question automatically to get (2) as an answer, then move to the next question.

Thabiso
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Answering Calculations

Post by josh »

If your dictionary variables are Q1, Q2 and Q3 respectively then you could add the following in the PREPROC of Q3:

Code: Select all

Q3 = Q1 + Q2;
noinput;
Thabs
Posts: 3
Joined: November 24th, 2014, 11:58 am

Re: Answering Calculations

Post by Thabs »

HI Josh

Thanks for the formula...

now here another dilemma.

I need a Auto-Complete formula

eg. Q1. Have you ever of Ebola? 1) Yes
2) No
3) I have never heard of Ebola

Q2. Do you know Ebola? 1) Yes
2) No
3) I have never heard of Ebola

Q3. Have you seen a person with Ebola? 1) Yes
2) No
3) I have never heard of Ebola


so in this formula i want to select Q1 answer 3) and auto-complete 3) to Q2 and Q3 with an answer 3)

so that it shouldn't be captured manually.

thanks

Thabiso
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Answering Calculations

Post by josh »

I'm not sure if I'm interpreting what you said correctly but in any case the idea would be to use the if statement in the preprocs of Q2 and Q3 to prefill the value if the value entered for Q1 is 3. Something like:

Code: Select all

PROC Q2
preproc

// prefill with "I have never heard of Ebola" if they answered same for Q1
if Q1 = 3 then
  Q2 = 3;
  noinput;
endif;

PROC Q3
preproc

// prefill with "I have never heard of Ebola" if they answered same for Q1
if Q1 = 3 then
  Q3 = 3;
  noinput;
endif;

MrTaco
Posts: 128
Joined: November 18th, 2014, 1:55 am

Re: Answering Calculations

Post by MrTaco »

Thank you Josh

That's exactly what i want

Thank you so much...
MrTaco
Posts: 128
Joined: November 18th, 2014, 1:55 am

Re: Answering Calculations

Post by MrTaco »

Hi Guys

This skip statement has been working nicely now it's no longer working

PROC Q_247

//if Q_247 = 1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9 or 10 or 11 or 12 or 13 or 14 or 15 or 17 or 97 or 98 then skip to Q_249; endif
I used to code this skip statement
but now it's not working like it used to..

on this question only 16 that goes to Q_248

please guys
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Answering Calculations

Post by josh »

Instead of if Q_247 = 1 or 2 or 3 or 4 or 5 or ... you probably want if Q_247 = 1 or Q_247 = 2 or Q_247 = 3 or Q_247 = 4 or Q_247 = 5 or ...

Alternatively you can use the "in" operator:

if Q_247 in 1:15, 17, 97, 98 then ...
MrTaco
Posts: 128
Joined: November 18th, 2014, 1:55 am

Re: Answering Calculations

Post by MrTaco »

PROC Q_265

if Q_265 = 2 then skip to Q_266; endif;
if Q_265 < 2 then skip to Q_267; endif;
if Q_265 > 2 then skip to Q_267; endif;

or

PROC Q_247
if Q_247 = 16 then skip to Q_248; endif;
if Q_247 < 15 then skip to Q_249; endif;
if Q_247 > 16 then skip to Q_249; endif;


hey Josh i managed to try this code and it worked well..

Thanks a million

Thabiso
MrTaco
Posts: 128
Joined: November 18th, 2014, 1:55 am

Re: Answering Calculations

Post by MrTaco »

Good day guys

I am trying to make a calculations of this questions but it can't work okay if am using this code:
but this code is okay coz I add "0" if they didn't answer but if am adding "missing" it doesn't calculate..
PROC Q2_O

preproc
Q2_O = Q2_A or missing + Q2_B + Q2_C + Q2_D + Q2_E + Q2_F + Q2_G + Q2_H + Q2_I + Q2_J + Q2_K + Q2_L + Q2_M + Q2_N ;
noinput

but this code is okay coz I add "0"

PROC Q2_O

preproc
Q2_O = Q2_A + Q2_B + Q2_C + Q2_D + Q2_E + Q2_F + Q2_G + Q2_H + Q2_I + Q2_J + Q2_K + Q2_L + Q2_M + Q2_N ;
noinput


how do I get it done

Regards
Thabiso
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Answering Calculations

Post by josh »

What are trying to do with the code "Q2_A or missing + Q2_B "? Q2_A is numeric value and missing is a special value so applying the "or" operator to them is undefined. It seems likely that you need an if statement somewhere like:

if Q2_A = missing then ...
Post Reply