The selectby tag with the steps method (alias step or stepwise) defines a multi-step selection process for variables, allowing different selection rules at each step.
set list: BRANDS
1. Coke
2. Dr Pepper
3. Pepsi
4. Sprite
5. Diet Coke
6. Mountain Dew
7. Coke Zero
8. Diet Pepsi
9. Fanta
10. Canada Dry Ginger Ale
7. Which of the following brands have you heard of?
type: checkbox
optsfrom: BRANDS
8. Which of the following brands have you ever purchased?
type: checkbox
optsfrom: BRANDS {if anyChecked($Q7,[id])}
99. None
9. Which of the following brands have you purchased in the past three months?
type: checkbox
optsfrom: BRANDS {if anyChecked($Q8,[id])}
99. None
10. Which brand is your favorite?
type: radio
optsfrom: BRANDS
BRANDS. 2 Brands for deep dive
type: quotas
selectby: steps
optsfrom: BRANDS
maxgroups: 2
steps:
1. Primary brand {if anyChecked($Q10,[id])} {maxgroups: 1} {selectby: condition}
2. Purchased competitor [1,3,5,7,8] {if anyChecked($Q8,[id])} {maxgroups: 1} {selectby: condition}
3. Recent brand {if anyChecked($Q9,[id])} {maxgroups: 2} {selectby: counts}
4. Other brands {if anyChecked($Q7,[id])} {maxgroups: 2} {selectby: counts}Details
-
selectby: stepscan be used ontype: checkbox,type: coded multiple select, andtype: quotasquestions. - The
selectby: stepsvariable requires that amaxgroupstag be included at the parent level. - The
selectby: stepsprocess cannot be combined with other selection methods and cannot be used at the same time as thecross bytag. - Each step must have the following decorators: a condition,
maxgroups, andselectby. -
apply ifcan be included on any steps that should only be applied to certain respondents.. - If needed, you can filter the option set with inclusion/exclusion and option data syntax.
- Steps are evaluated in the order they are programmed.
- By default,
selectby: stepsautomatically creates a unique variable to store the data for each step. The step variables are located in the Survey fields chapter along with the parent step variable. Apply thesteps chaptertag to change the step question's location in the reporting field tree.
Understanding step selection behaviors
There are several step behaviors that are helpful to understand.
- An item selected in an earlier step cannot be chosen in a later step.
- Step selections keep a running count of the total selected items. A later step cannot exceed the remaining number needed, regardless of the
maxgroupsallowance on that step. - Each step establishes its own
selectbyprocess.- A step's selection process can be tiered, such as
selectby: counts, weight. - A step cannot use
selectby: steps,selectby: percentage, orselectby: balancein its own selection process.
- A step's selection process can be tiered, such as
Additional examples
Including and excluding options
Using the same list and variables as the example above, the following shows how specific options can be included or excluded for the individual steps. In this case, only colas ever purchased will be included in step 1, and the colas will be excluded from step 2.
BRANDS. 2 Brands for deep dive
type: quotas
selectby: steps
optsfrom: BRANDS
maxgroups: 2
steps:
1. Colas ever purchased [1,3,5,7,8] {if anyChecked($Q8,[id])} {maxgroups: 1} {selectby: condition}
2. Non-colas ever purchased -[1,3,5,7,8] {if anyChecked($Q8,[id])} {maxgroups: 1} {selectby: condition}
3. Any soda heard of {if anyChecked($Q7,[id])} {maxgroups: 2} {selectby: counts}
Using 'apply if' at the step level
In the following example, Q2COLOR will select two colors based on the weighted option responses to QCOL. In this setup, Step 1 of Q2COLOR will only apply to Men and Step 2 will only apply to Women based on the response to QGEN.
GEN. What is your gender?
type: radio
1. Male
2. Female
set list: COLORS
1. Red {{mweight: 2}} {{fweight: 0}}
2. Blue {{mweight: 2}} {{fweight: 0}}
3. Yellow {{mweight: 2}} {{fweight: 0}}
4. Orange {{mweight: 0}} {{fweight: 2}}
5. Purple {{mweight: 0}} {{fweight: 2}}
6. Green {{mweight: 0}} {{fweight: 2}}
COL. Which colors are you aware of?
type: checkbox
opts from: COLORS
2COLOR. Pick colors
type: coded multiple select
maxgroups: 2
selectby: steps
opts from: COLORS
steps:
1. Men {if anyChecked($QCOL,[id])} {maxgroups: 2} {selectby: weight} {weight: [mweight]} {apply if: anyChecked($QGEN,1)}
2. Women {if anyChecked($QCOL,[id])} {maxgroups: 2} {selectby: weight} {weight: [fweight]} {apply if: anyChecked($QGEN,2)}
Comments
0 comments
Please sign in to leave a comment.