Creating a Nested Banner
Jump to navigation
Jump to search
The script below shows an example of how to generate a banner using QScript. In most cases it is not necessary to create banners with a script because banners can be created using Create > Banner > Drag and Drop.
// Working on Phone.sav, this creates a new banner question
// with 'Gender' nested under 'Age'. The banner question can then
// be selected in the blue or brown dropdown.
var data_file = project.dataFiles[0];
data_file.createBanner("Demographic banner with nesting",
[[data_file.getQuestionByName('Age'),
data_file.getQuestionByName('Gender')],
[data_file.getQuestionByName("Work status")]]);
See also
- QScript for an explanation of how to run this code.
- QScript Examples Library for other examples.
- QScript Reference for technical information.
- JavaScript for information about the JavaScript programming language.
- Table JavaScript and Plot JavaScript for tools for using JavaScript to modify the appearance of tables and charts.
- JavaScript Variables for detail on how to create new variables in the Variables and Questions tab using JavaScript.