Rebasing a Pick One Question

From Q
Jump to: navigation, search

This page describes how to rebase data automatically using a QScript. If you are just looking to rebase a single question it is easier to do so directly on the table - see Hiding and Removing Categories (Missing Values).

This removes the 'Don't know' category from a Pick One question and sets it as missing (i.e., so that the table is automatically rebased when the question is used).

This example can be run in C:\Program Files\Q\Examples\Phone.sav (this may be located on a different place on your computer depending upon how Q was installed).

var age = project.dataFiles[0].getQuestionByName('Age');
var dk_value = age.valueAttributes.getSourceValueByLabel("Don't know");
age.valueAttributes.setIsMissingData(dk_value, true);

The second line of this code works out what value has been assigned to 'Don't know' in the data file.

The third line sets this value as missing (i.e., which is equivalent to right-clicking on the category in the Outputs Tab and selecting Remove.

See also