This article describes how to use a built-in QScript to create a chart for every question in your dataset.
Requirements
A data file loaded in Q
Method
To run this QScript, select Automate > Browse Online Library > Preliminary Project Setup > Summary Visualizations.
A chart will be created for every question in the data file (excluding those that are marked as hidden).
Example
QScript
This code is included for reference only and is not necessary to run the automation in Q.
// also imports QScript Utility Functions for inDisplayr
includeWeb("QScript Selection Functions");
includeWeb("QScript Functions to Generate Outputs");
const is_displayr = inDisplayr();
const data_file = requestOneDataFileFromProject(true);
// From here a user will have selected a file or only have one possible file in the document.
const on_page = onPages("summary visualizations");
function entirelyMissing(question) {
return question.variables.every((v) => {
let vattr = v.valueAttributes;
return v.rawValues.filter(x => !Number.isNaN(x) &&
!vattr.getIsMissingData(x)).length === 0;
});
}
let questions = data_file.questions.filter(q => !q.isHidden &&
q.isValid &&
q.questionType.indexOf("Text") == -1 &&
!entirelyMissing(q)).map(q => ({
primary: q,
secondary: "SUMMARY"
}));
let page_names = questions.map(q => q.primary.name);
let report = createReport("Summary Visualizations", questions, page_names, null, null, [], false, Infinity, false, true, !on_page);
if (report.subItems.length == 0)
log('No visualizations were created. All variables in the data file are either text, ' +
' hidden, or contain entirely missing values.');
else if (!is_displayr)
conditionallyEmptyLog('A group of summary visualizations has been added to the project.');
Next
How to Use Scripts to Automate Data Checking and Cleaning
How to Check for Errors in Data File Construction
How to Identify Questions with Straight-Lining/Flat-Lining
How to Create New Variable(s) with Outliers Removed
How to Hide Uninteresting Data
How to Remove Truncated Text from Variable Labels
How to Reverse Scales in Questions
How to Suggest Better Question Names from Source Labels