In the Introduction to order tags article, we explain the basic usage of the order
tag. This article provides additional advanced examples of how to apply explicit order strings and use independent variables.
Examples
Ordering with independent variables
Some situations require specific order assignments beyond what can be defined with an order
tag — for example, using one order for exactly half of respondents, and the reverse order for the other half. To accommodate these and similar requests, the order
tag can accept a variable as an input. This allows us to apply programming logic such as cvalue
or selectby
to the order.
Note, the variable containing the order must be populated with data before it can be used.
Open-end variables
To define an order within a text variable, put the numeric string in the variable using cvalue
and surround the string with single quotes. In the example below, the Q1TO5ORDERVAR variable assigns anyone who selected option 1 at Q1 the value '1, 2, 3, 4, 5', while those who select option 2 at Q1 are assigned '5, 4, 3, 2, 1'. Then, the order
tag will use the value stored at Q1TO5ORDERVAR as its input.
1. Please select the option order:
type: radio
1. Increase on the left
2. Decrease on the left
1TO5ORDERVAR. Ordering Variable
type: text
invisible: y
cvalue: <<END
if (anyChecked($Q1,1)) {'1,2,3,4,5'}
else {'5,4,3,2,1'}
END
2. What do you expect will happen in the next five years?
type: radio
order: $Q1TO5ORDERVAR
1. My spend will greatly increase
2. My spend will moderately increase
3. My spend will stay the same
4. My spend will moderately decrease
5. My spend will greatly decrease
Closed-end variables
In the following example, Q5ORDERVAR is a radio variable that alternates between sequential and reverse orderings for positions 1, 2, 3, 4, and 5. The selectby: counts
tag ensures that half of the respondents see the options in increasing order, while the other half see them in decreasing order.
5ORDERVAR. Ordering Variable
type: radio
selectby: counts
1. 1,2,3,4,5
2. 5,4,3,2,1
5. What do you expect will happen in the next five years?
type: radio
order: $Q5ORDERVAR
1. My spend will greatly increase
2. My spend will moderately increase
3. My spend will stay the same
4. My spend will moderately decrease
5. My spend will greatly decrease
Ordering with the order() method
If you are using an independent variable but need to include ranges or square brackets '[ ]' for randomization, use the order()
method. This method allows you to define an order with ranges and brackets in a standalone custom ordering variable. However, note that the order()
method does not support anchored elements ('$','^') or "wildcards" ('*'). In the example below, options 1, 2, and 3 will be randomized, but option 4 will always be last.
ORDERVAR.
invisible: y
type: text
cvalue: order('[1..3],4')
In this next example, Q8ORDER selects option 1 or 2, to assign either an ascending or descending order. If Q8ORDER = 2, Q8ORD assigns the order '5, 4, 3, 2, 1'. Otherwise, Q8ORD assigns the order '1, 2, 3, 4, 5'. The order
tag at Q8 then receives either of these numeric strings as the input.
8ORDER. Q8 Likert scale order
type: coded single select
selectby: counts
1. Ascending (Not at all likely -> Very likely)
2. Descending (Very likely -> Not at all likely)
8ORD. Q8 Likert scale order
type: text
invisible: y
cvalue: order( $Q8ORDER == 2 ? '(5..1)' : '(1..5)' )
chapter: logic
8. How likely are you to purchase this brand?
type: radio
order: $Q8ORD
1. Not at all likely
2. Somewhat likely
3. Neutral
4. Somewhat likely
5. Very likely
Tip! The order()
method is often used in conjoints to define the task order.
Randomizing sets of options while keeping certain options together
Explicit order strings are highly flexible. In the example below, items 1, 2, and 3 must stay together, but their order can be randomized. Similarly, items 4 and 5 must stay together, with their order also randomized. Finally, the groups themselves — 1-3, 4-5, and 6 — are randomized.
3A. Please select one.
type: radio
order: [[1,2,3],[4,5],6]
optsfrom: series[1..6]
Randomizing sets while anchoring a middle point
Building on the previous example, we can incorporate an anchored midpoint. In the example below, groups of options are randomized within their respective groups. Additionally, the first and second sets are randomized between the two groups. However, row 99 will always be anchored in the fifth position.
11. How much do you agree/ disagree with each of the following statements?
instruct: Select one response per statement.
type: radio table
failif: anyChecked($Q11R99) and noneChecked($Q11R99,4)
1. Strongly disagree
2. Disagree
3. Somewhat disagree
4. Somewhat agree
5. Agree
6. Strongly agree
rows:
order: [[1..4],^5,[6..9]]
1. I prioritize taking care of my face since it's the first thing people notice
2. I enjoy discovering beauty brands on social media
3. I will pay more for a product that has "clean" ingredients
4. I will pay more for products that align with my values
99. For quality purposes, please select 'Somewhat Agree'
5. Good value for money is a top priority for me
6. I am usually the first one to try new beauty products
7. I typically combine products from different beauty brands
8. I look for products that "cure" my skin concerns (e.g., eczema, rosacea, acne)
Comments
0 comments
Please sign in to leave a comment.