I have actual age in data set. I would like to create a new variable called Age Group. So, if [Age] => 25 and < 35, then Age Group = 25-34 Else, if [Age] => 35 and <45 then Age Group = 35-44, Else, ...and so forth to [Age] > 64, Age Group = "65+"
Straight forward market research calc, just struggling with Formula tool logic??
Thanks
Solved! Go to Solution.
Hi @BarleyCorn,
IF age < 25 Then "24 or Less' ELSEIF AGE < 35 then ' 25 to 34' ELSEIF age < 45 then ' 35 to 44' ELSE "Just getting started" ENDIF
The problem that you were having is:
IF. Age > 24 AND Age < 35 Then '25 - 34' ELSEIF
you need to structure the AND with two complete comparisons.
I simplified the statements because once you test for the lower range you don't have to test it again. Once you have eliminated under 25 when you test for under 35, then the group must be 25 to 34.
I I hope that this helps?
Mark
Hi MarqueeCrew,
The following still gets an error?
IF [Age] < 25 then "24 or less" ELSEIF
[Age] < 35 then "25 to 34" ESLEIF
[Age] < 45 then "35 to 44" ELSEIF
[Age] < 55 then "45 to 54" ESLEIF
[Age] < 65 then "65+" ELSE
ENDIF
Getting "Parse error at Char(167) Un known variable "ENDIF" ??
Hi @BarleyCorn!
2 things and then you should have it. 1) You have 2 spelling errors (both cases "ESLEIF" instead of "ELSEIF") and 2) you need to have something between the last ELSE and the ENDIF. In other words, what do you want the Formula to return if none of the other IFs are met (like when age is > 65)?
IF [Age] < 25 then "24 or less" ELSEIF [Age] < 35 then "25 to 34" ELSEIF [Age] < 45 then "35 to 44" ELSEIF [Age] < 55 then "45 to 54" ELSEIF [Age] < 65 then "55 to 64" ELSEIF
[Age] > 64 then "65+" ELSE "UNKNOWN" ENDIF
A few fixes:
New variable is "Vstring"
final ELSEIF is ELSE
Very Close!
The module is attached.
Cheers,
Mark
Thats it!! - Thanks Mark!