How To Code A Subset Of Responses

From Q
Jump to navigation Jump to search

Sometimes it is useful to code only some of the responses to a question (i.e., to filter the responses by some criteria, prior to dong the coding).

For example, coding only the responses of people who gave a satisfaction rating of 9 or 10. This is as follows:

  • In the Variables and Questions tab, right-click on the text variable and select Copy and Paste Variable(s) > Linked.
  • Right-click on the newly-created variable and select Edit Variable.
  • The Expression will contain the variable's name (e.g., q6oe). Modify this expression so that it reflects the logic you wish to apply. For example, this expression filters out all the text data other than for people with a rating of 9 or 10 on d1: if (d1 == 9 || d1 == 10) q6oe. Press OK.
  • Code the newly-created variable. You can re-use any coding again if you decide at a later stage to code all the data.

If wanting to code a randomly selected subset of data, the process is slightly different.

  • Create a filter variable that selects respondents to go into your sample - see How to Randomly Select a Sub-Sample.
  • Follow the steps above. Your Expression in step 3 would be similar to : if (randomfilter == 1) q6oe; else NaN;