Recode Numeric Values to Categories

Top  Previous  Next

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

_img440

Much data come with categories coded numerically rather than as words. But when you’re doing data analysis with Fathom, you want the categories to be words you can read, not numbers you have to keep translating.

Recoding is done with the switch function, which is a conditional function that acts like a complicated if-statement.

The collection here has two numerically coded attributes: sex: 1 = "Female", 2 = "Male"; education: 1 = "High School", 2 = "College No Degree", 3 = "College Degree", 4 = "Graduate Work"

1.Add two attributes: sexDecode and edu.
2.Double-click the formula cell for sexDecode to show the editor.
3.Enter this formula:

_img441

 

Tab to move in the switch function. To insert the second option, press Insert, or Ctrl+Enter (Win) Option+Enter (Mac).

You should include the “Other” value in the formula so that wrongly entered data and missing values don’t get coded as male.

4.Similarly, give edu this formula:

_img442

 

Here are the results, shown in a case table:

_img141

 

You could now clear the recoding formulas and even delete the original attributes.