Surveys often include open-ended questions which must be re-coded as closed-end hidden variables in order to ease data analysis. A common example is the age question, where respondents type in their exact age, and a hidden variable calculates their age range based on a list of ranges. Historically, survey programmers have had to add this hidden variable and write conditions for each range in the list (e.g., 25-34 {if $QAGE >=25 and $QAGE <=34}
) manually.
The create_closed
tag, when applied directly to the text question and referring to a properly formatted list, does this automatically. If need be, the tag may be applied multiple times on a question to create different closed-ended variations from a single open-ended variable.
Syntax
Whether spaces are used before and after the hyphen in a list's ranges does not matter - both '19-29' and '19 - 29' are accepted by the system.
# basic create_closed: QVARIABLE {list_id: LIST_USED} {desc: Description} # creating list ranges for 'create_closed' set list: LIST1 1. 0-19 2. 20-29 3. 30-39 4. 40-59 # creating list ranges that allow for values below and above in a range (e.g., "less than or equal to 19", "greater than or equal to 40") set list: LIST2 1. -19 2. 20 - 29 3. 30 - 39 4. 40+
Note: If a list used by create_closed
has ranges with overlapping options or gaps, parse errors may occur and the code may not compile.
Examples
Basic usage
In the following example, respondents are asked to input their age. The create_closed
tag is then used to create the QAGE1 variable and uses the AGE_RANGE list to assign respondents to whichever age range they belong.
Notice that the desc
modifier can be used to clarify how the ranges/list are defined so that these variables are easier to understand in the survey's reports. We will cover this in more detail below.
Applying multiple create_closed tags
Open-ended response questions may also accept multiple create_closed
tags, with each usage of the tag creating its own variable. In the following example, two different lists are established to define the variables QINC1 and QINC2. The list INCOME defines narrower ranges (and thus more bucket groups) for the QINC1 variable, whereas the list INCOMEGRP uses a smaller number of wider response ranges, reflecting how income brackets are traditionally broken down in the United States. The results of which groups the respondent will end up in are piped into follow-up statements on the next page of the survey.
As mentioned above, the lower end of the response range may be defined in an "open-ended" way - e.g., both '1. 0-24999' and '1. -24999' are interpreted the same way.
create_closed in reports
Since create closed
can be applied once or multiple times to a question, creating a variable for each instance, each new variable will have its own set of respondent data. Using the examples above, notice the differences in the Response Report and Topline Report tiles for QSAGE and QAGE1, and QINC with QINC1 and QINC2.
The responses for QSAGE and QINC both display the initial, open-ended responses, whereas the variables created from the create_closed
tags (QAGE1 and QINC1/QINC2, respectively) display the option ranges each response is assigned to.
In the Topline Reports, QSAGE defaults to displaying as a bar graph with the average age response, and QAGE1, which uses the list AGE_RANGE, displays the results for each of the 8 defined age ranges (see above).
Note that the text from the desc
decorator used to define QAGE1 is shown above the bar graph (right) as opposed to using the question/variable text as shown in QSAGE.
Although QINC1 is defined by a list that contains 9 options and QINC2 by a list that contains 5 options (see above), there is some overlap in these group definitions. Both variables are defined by a list whose 3rd options start at 50000, although QINC2 has a much larger range, incorporating all of QINC1's 4th option ('75000 - 99000') into its 3rd option range as well.
The desc
decorator may also be applied to the elements in the lists that define the ranges for the variables defined by create_closed
as well, allowing for each range to display the description instead of the numerical range. In the below example, QINC and its lists have been modified so that each list item includes a description that will appear in the Topline Tile. This is especially useful for the INCOME2 list, where the range options are based on socioeconomic classes and the class grouping might be of more importance than the actual income range that defines it.
Code | Topline Tile Output |
---|---|
set list: INCOME1 1. -24999 {desc: <$25k} 2. 25000 - 49999 {desc: $25k up to $50k} 3. 50000 - 74999 {desc: $50k up to $75k} 4. 75000 - 99999 {desc: $75k up to $100k} 5. 100000 - 149999 {desc: $100k up to $150k} 6. 150000 - 199999 {desc: $150k up to $200k} 7. 200000 - 249999 {desc: $200k up to $250k} 8. 250000 - 349999 {desc: $250k up to $350k} 9. 350000+ {desc: >350k} set list: INCOMEGRP1 1. -29999 {desc: Lower class} 2. 30000 - 49999 {desc: Lower-middle class} 3. 50000 - 99999 {desc: Middle class} 4. 100000 - 349999 {desc: Upper-middle class} 5. 350000+ {desc: Upper class} INCA. What is your current <b>total annual household</b> income? type: text datatype: whole prefix: $ dta: y dta_text: I'd prefer not to answer. dtaid: 99 create closed: QINC1A {list_id: INCOME1} {desc: More Income Range Options} create closed: QINC2A {list_id: INCOMEGRP1} {desc: Income Brackets} |
|
Comments
0 comments
Please sign in to leave a comment.