Hiding a Category of a Question
Removes a category from a question but does not rebase it. This is automating the process of right-clicking on a category and selecting Hide.
var age = project.dataFiles.getQuestionByName('Age'); age.dataReduction.hide("Don't know");
The first line of this code finds a question named Age in the first data file (note that  finds the first data file,  would find the second, etc. ) and assigns it to a variable called age.
The second line of the code modifies the question called age. It does so using the question’s DataReduction. The DataReduction is the object that stores which categories have been merged together, which have been hidden, what their names are and what order they are shown in. Thus, the hide instruction is hiding the Don’t know category and this will cause the category not to appear when this question is used to create tables and charts.
- Next worked example.
- QScript for an explanation of how to run this code.
- QScript Examples Library for other examples.
- QScript Reference for technical information.