Creating a Frequency Table
// Working on Phone.sav, this creates a new frequency table of Age. var t = project.report.appendTable(); t.primary = project.dataFiles.getQuestionByName('Age'); t.secondary = "SUMMARY";
- project.report.appendTable() tells Q to append a table to the project’s report tree.
- var t = tells Q to refer to the table that has been created as t in the rest in the script.
- The second and third line of the code tell Q which questions to select in the blue and brown drop-downs respectively. In this example, we have created a frequency table by selecting SUMMARY in the brown drop-down. To instead create a crosstab of age by gender:
var t = project.report.appendTable(); t.primary = project.dataFiles.getQuestionByName('Age'); t.secondary = project.dataFiles.getQuestionByName('Gender');
- Next worked example.
- Preliminary Project Setup - Summary Tables for a QScript to generate a summary table for each question in your project.
- QScript for an explanation of how to run this code.
- QScript Examples Library for other examples.
- QScript Reference for technical information.