RECODE

What Is It?

The most frequently used action command due to its versatility, Recode can be used to automatically enter values based on specified rules.

Available for: Single, Multi, Verbatim, and Verbatims questions.

How Do I Specify It?

  1. Right mouse-click on the target variable in the Designer Panet Which Question Type Should I Use for the Target Variable?
  2. Select Action Command from the Quick Menu
  3. Select RECODE from the drop-down list
  4. Enter the recode command (see guide below)
  5. Click "OK" to close the dialogue box.

The rules for specifying recodes are based on Boolean logic Boolean Basics.

Which Question Type Should I Use for the Target Variable?

The question type for the target question should be chosen based on the data structure required:

Question Type Text input? More than 1 possible answer? Coded responses? Numeric input?
Single N N Y Y
Multi N Y Y N
Verbatim Y N N Y
Verbatims Y Y N Y

Examples of Use

Simple Recodes

Source Variable/s Target Variable Recode
Single (Q1) Single WHEN @Q1=1 THEN 4 END,
WHEN @Q1=2 THEN 5 END,
Single (Q1) Multi WHEN @Q1=1 THEN 4|1 ELSE 4|0 END,
WHEN @Q1=2 THEN 5|1 ELSE 5|0 END,
Multi (Q1) Multi WHEN @Q1_1=1 THEN 4|1 ELSE 4|0 END,
WHEN @Q1_2=1 THEN 5|1 ELSE 5|0 END,
Single (Q1) Verbatim WHEN @Q1=1 THEN 'Male' END,
WHEN @Q1=2 THEN 'Female' END,
Multi (Q1) Verbatim WHEN @Q1_5=1 THEN 'Fifth answer selected in Q1' END,
Single - numeric (Q1) Single WHEN @Q1<18 THEN 1 END,
WHEN @Q1>=18 THEN 2 END,
Verbatim- text (Q1) Single WHEN @Q1=’Male’ THEN 1 END,
WHEN @Q1=’Female’ THEN 2 END,
Single Response Grid (Q1) Single

WHEN @Q1_1<5 THEN ‘Less than 5 in first grid item' END,
WHEN @Q1_2<5 THEN 'Less than 5 in second grid item' END,

Single (Q1 & Q1RANDOM) Single WHEN @Q1=4 then @Q1RANDOM else @Q1 end,
Verbatims MVerbatims WHEN @Q1_1 is not null THEN 1|@Q1_1 END,

Multi condition recode:

Source Variable/s Target Variable Recode
Single(Q1), Multi (Q2) Single WHEN @Q1 = 1 AND (@Q2_1=1 OR @Q2_2=1) THEN 8 END

Recoding responses in a defined range:

Source Variable/s Target Variable Recode
Single - numeric (AGE) Single WHEN (@AGE > 17 AND @AGE < 25) THEN 2 END,
Single - numeric (AGE) Single - numeric WHEN @AGE BETWEEN 18 AND 25 THEN 21.5 END

Recoding similar responses:

Source Variable/s Target Variable Recode
Sample – verbatim (Date) Single WHEN @Date LIKE '2016-03-%' OR @Date LIKE '%.03.2016' THEN 1 END
Verbatim- text (Q2) Multi when @Q2 like '%cat%' then 1 end,
when @Q2 like '%dog%' then 2 end,

Creating an image reference for display in another question:

Source Variable/s Target Variable Recode
Single Verbatim WHEN @Animal=3 THEN 'tiger.png' END 

Concatenating text:

Source Variable/s Target Variable Recode
Single (Q1), Verbatim- text (ZooName)  Verbatim WHEN @Q1=3 THEN 'Which animals did you see at ' + @ZooName + '?' END
Verbatim- text (ZooName)  Verbatim WHEN 1=1 THEN 'Which animals did you see at ' + @ZooName + '?' END

Recode based on count of answers:

Source Variable/s Target Variable Recode
Multi (Q1) Single WHEN @Q1_Count>0 THEN 1 ELSE 2 END

Recoding a list of values in a single command:

Source Variable/s Target Variable Recode
Single (StoreID) SSingle WHEN @StoreID in (471,499,4929,4933,4934,429,876) THEN 1 ELSE 2 END

Unconditional recodes:

Source Variable/s Target Variable Recode
None Multi WHEN 1 = 1 THEN 1 END,
WHEN 2 = 2 THEN 2 END,
WHEN 3 = 3 THEN 3 END,

Recoding blank answers:

Source Variable/s Target Variable Recode
Verbatim- text (Q1) Single WHEN @Q1=’’ OR @Q1 is null THEN 2 ELSE 1 END,

Recode based on any answer provided:

Source Variable/s Target Variable Recode
Verbatim- text (EmailAddress) Single WHEN @EmailAddress<>’’ THEN 1 END,
Multi (Q1) Multi WHEN @Q1_1 IS NOT NULL THEN 1|@Q1_1 END,
WHEN @Q1_2 IS NOT NULL THEN 2|@Q1_2 END,

Mathematical computations:

Source Variable/s Target Variable Recode
Single – numerical (Q1,Q2,Q3,Q4) Single - numerical WHEN 1=1 THEN (@Q1 + @Q2 + @Q3 + @Q4) END,
Single – numerical (Q1,Q2) Single - numerical WHEN 1=1 THEN (@Q1*(@Q2/100)) END,
Verbatims - numerical (Q1) Verbatim WHEN 1=1 THEN (@Q1_1 + @Q1_2 + @Q1_3 + @Q1_4) END,

Flag expired survey:

Source Variable/s Target Variable Recode
Global Variable (InvitationSent,CurrentDate) Single WHEN datediff(day,@InvitationSent,@CurrentDate)>=7 THEN 1 ELSE 0 END