How to Use Search/Replace to Conditionally Recode Lots of Variables

From Q
Jump to: navigation, search

This page describes how to use Search/Replace to change automatically change the Expression field in multiple variables. This is demonstrated using a Pick Any - Grid question called Q5. Brand associations in c:\Program Files\Q\Examples\cola.Q.

It is important to appreciate that this example is designed to illustrate the mechanics of using the Search/Replace function to modify expressions and a better way of doing the specific task demonstrated on this page is to use either a filter or QScript (in particular, see Rebasing Questions Using a Condition).

  1. In the Variables and Questions tab select the question to be copied.
  2. Right-click and select Copy and Paste Questions > Linked.
  3. Right-click and select Search/Replace : Formulas.
  4. Enter * in the Find what box (see wildcards for an explanation).
  5. Enter if (Q2 == 1) ${0}; else 0 in the Replace with box. Note that this will "if (Q2 == 1); " before whatever is currently in the Expression field for each variable and "; else 0" at the end of the Expression. Thus, this example replaces the current value with a 0 if the respondent has a value of 1 in Q2 and otherwise it leaves the value unchanged.

See also

Personal tools