Professional > Data management scripting > Data Management reference > Data Management functions > SubtractQuestion
 
SubtractQuestion
Subtracts the values for one or more questions (used for OnNextCase events).
Syntax
SubtractQuestion(ResultCat, CatVar1, CatVar2,...)
Parameters
CatVar1
Type: object
Categorical question
CatVar2
Type: object
Categorical question
ResultCat
Type: object
Categorical question.
ResultCat.Response.value = catVar1.Response.Value - catVar2.Response.Value-…-catVarN.Response.Value
(return)
Type: Categorical
ResultCat.Response.Value
Notes
The value for question being subtracted from the first question (CatVar1) can be zero. In this case, the ResultCat value is same as the CatVar1 value.
There are restrictions when using this function:
Questions can contain special responses, such as DK / NA/ REF, but the questions will be adjusted to the related special response for CatVar1.
Example
SubtractQuestion(Result4, Spont, Prompt1, Prompt2, Prompt3)
The definitions for Result4, Spont, Prompt1, Prompt2, and Prompt3 are as follows:
Spont categorical [1..]
{
Dog -,
Goldfish -,
Panda -,
Giraffe -,
snake -,
SpontDK - DK,
SpontREF - REF,
SpontNA - NA
};

Prompt1 categorical [1..]
{
Dog -,
Goldfish -,
Panda -,
Giraffe -,
snake -,
Prompt1DK - DK,
Prompt1REF - REF,
Prompt1NA - NA
};

Prompt2 categorical [1..]
{
Dog -,
Goldfish -,
Panda -,
Giraffe -,
snake -,
Prompt2DK - DK,
Prompt2REF - REF,
Prompt2NA - NA
};

Prompt3 categorical [1..]
{
Dog -,
Goldfish -,
Panda -,
Giraffe -,
snake -,
Prompt3DK - DK,
Prompt3REF - REF,
Prompt3NA - NA
};
Result4 "What animal you like? (Do not read the list)" categorical [1..]
{
Dog "Dog",
Goldfish "Goldfish",
Panda "Panda",
Giraffe "Giraffe",
snake "snake",
SpontDK "SpontDK" DK,
SpontREF "SpontREF" REF,
SpontNA "SpontNA" NA
};
The related values are as follows:
Question
Case 1
Case2
Spont
{ SpontRef }
{SpontDK}
Prompt1
{snake,Griaffe,Goldfish }
{Prompt1DK}
Prompt2
{ dog,goldfish,giraffe }
{Prompt2NA}
Prompt3
{giraffe,dog}
{ Prompt3NA }
Result4
{ SpontRef }
{ }
See also
Data Management functions