One user asked: What's the best way to compute Means for age or income category questions? Do I create a recoded variable converting the categories into the midpoint values? Or do I do it using syntax in RB? (e.g., %($25K-$50K)*37.5))+ %($50K-$75K)*62.5.5))+…)
Is there another method?
Another user asked: How can we do a grouped mean? For example, we have different age buckets but I would like to report out on the midpoint mean.
I think the syntax allows it now. But it's not easy: use the syntax: test_condition ? result_if_true : result_if_false
which is similar to Excel's syntax if(test_condition, result_if_true, result_if_false)
.
For example:
avg( (q1>=20 and q1<=29) ? 24.5 : (q1>=30 and q1<=39) ? 34.5 : (q1>=40 and q1<=49) ? 44.5 : null )
Comments