This example 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 in Q and Hiding and Removing Categories in Displayr.
Method
This removes the 'Don't know' category from a Pick One/Nominal variable and sets it as missing (i.e., so that the table is automatically rebased when the question is used).
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 table and selecting Remove.