Creating a Frequency Table

From Q
Jump to navigation Jump to search

Adds a new table to the Report containing a SUMMARY of a Pick One question.

// Working on Phone.sav, this creates a new frequency table of Age.
var t = project.report.appendTable();
t.primary = project.dataFiles[0].getQuestionByName('Age');
t.secondary = "SUMMARY";

Note that:

  • 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[0].getQuestionByName('Age');
t.secondary = project.dataFiles[0].getQuestionByName('Gender');

See also