Recode Ranges of Numeric Values to Categories

Top  Previous  Next

How To... > Work with Formulas > Work with the Formula Editor > Recode Ranges of Numeric Values to Categories

You can use the switch statement to recode ranges of numeric values to categories.

Suppose you have heights in inches and you want to group them as short, medium, and tall.

1.Define a new attribute called heightGroup.
2.Give it this formula:  

_img443

Tips for entering this formula:

You do not type the ? characters; Fathom enters them for you when you type the < or > characters.

To enter ≥, press Ctrl (Win) Option (Mac) and click the ≥ button on the formula editor keypad.

Tab to move to the next field.

To get a new line in the switch statement, press Insert or Ctrl+Enter (Win) Option+Enter (Mac).

If you get too many lines in your switch statement, you can get rid of them using Delete or Backspace until there is nothing left in the line.

You should include the “missing” line of the switch statement in case there are values that aren’t numbers. You could code this to an empty string, that is, nothing in between a pair of quotation marks, and that would allow Fathom to treat the missing values as truly missing.