Desktop User Guides > Professional > Data management scripting > Creating new variables > Example 7: Adding categories to existing variables
Example 7: Adding categories to existing variables
Sometimes you might want to add categories to variables that already exist in the metadata. For example, the Museum sample data set has a variable called Museums that records which other museums and galleries the respondent has visited. The following example shows how you could add new categories to this variable.
When you run the DMS file, UNICOM Intelligence Professional merges the new categories defined in the Metadata with the categories in the existing variable. If the definitions conflict, the definition in the existing metadata is taken as the master. In the merged metadata, the categories defined in the Metadata section will always appear after the existing categories.
Metadata(ENU, Question, Label, myInputDataSource)
museums "Museums and galleries visited or plans to visit"
{Museum_of_space "Exploration of Space Museum",
Modern_Art "Gallery of Modern Art"};
End Metadata
When you use this technique for adding categories to existing variables, make sure that you spell the name of the variable correctly and that you do not change the variable's type. If you spell the name differently in the Metadata section, UNICOM Intelligence Professional creates a new variable. However, an error occurs if you specify an existing variable's name but with a different type keyword. For example, an error occurs if the existing variable is defined as a numeric variable and you specify a categorical variable of the same name in the Metadata Section.
This example is in the NewVariables.dms sample DMS file. For more information, see Sample DMS files.
UNICOM Intelligence Professional
Creating new variables