See the following article for more information:
The DEFINE VIEW command allows you to create views from datasets by indicating a selection of variables, variable folders, and a filter to use. By default, the views are created in the current folder regardless of the dataset used.
You can also use CREATE VIEW FROM DATASET as an alternate command.
DEFINE VIEW FROM DATASET("my ds name")
FOLDERS "folder|path1", "folder|path2"
VARIABLES alias_list
FILTERED BY expression
NAME "My view";
Example Use Cases
For the following examples, suppose you would like to create a view of a dataset named "Sample Tracking Study" with the following variable folder structure:
1. View with all variables
If you'd like to create a view of the dataset and include all of the variables, you do not need to list all of the folders or variable aliases in the script. You can use VARIABLES ALL() to include them in a single command.
DEFINE VIEW FROM DATASET("Sample Tracking Study")
VARIABLES ALL()
NAME "View with all variables";This will result in a view that mirrors the source dataset's structure.
2. View with a subset of folders
Perhaps you need to share a view of the dataset that only includes the variables in the Demographics and Brand Image folders for a particular stakeholder.
DEFINE VIEW FROM DATASET("Sample Tracking Study")
FOLDERS "Demographics", "Brand Image"
NAME "View with subset of folders";This results in the following folder structure in the view:
3. View with a subset of variables
If you'd like to create a view of the dataset that only includes specific variables, you can list those by alias rather than variable title.
DEFINE VIEW FROM DATASET("Sample Tracking Study")
VARIABLES q2,q5_mr,s1,s3
NAME "View with subset of variables";This view will include the variables listed, maintaining the folder structure from the source dataset:
4. View with a subset of respondents
Another scenario could be that for this multi-country survey, you only want to share the respondents from a certain country in the view. This can be achieved by including the FILTERED BY criteria in the definition.
DEFINE VIEW FROM DATASET("Sample Tracking Study")
VARIABLES ALL()
FILTERED BY s3="England"
NAME "View with respondents from England";This view will only include those respondents, so the overall base will be updated for the dataset.
5. View with specific folders/questions/respondents
Lastly, all of the above commands can be combined to include whichever variables, folders, or respondents you'd like to include in the view.
DEFINE VIEW FROM DATASET("Sample Tracking Study")
FOLDERS "Awareness & Advertising", "Rebranding to Homeware Haven"
VARIABLES q5_mr,s1,s3
FILTERED BY s3="England" OR s3="Scotland"
NAME "View with specific folders/questions/respondents";This results in a view with all the variables in the two folders listed, only the selected variables in the other folders, and filtered to those in either country listed.