Coding a text variable into a numeric variable

Minitab can be used to translate or "code" a column of text values into another column of numeric values.

Minitab Procedure

  1. In Minitab 14, select Data >> Code >> Text to numeric... In Minitab 13, select Manip >> Code >> Text to numeric...
  2. In the box labeled Code data from columns, specify the name of the text variable that you want to code.
  3. In the box labeled Into columns, specify an empty column (or the name of the new numeric variable) in which you want the coded values to appear.
  4. For each value of the variable that you want to code, type the text value in the box labeled Original values and type its new numeric value in the box labeled New. Make sure you do this for every possible value of the text variable that you want to code.
  5. Select OK. The new numeric variable should appear in your worksheet.

Note: if you have more than one text variable to create, you have to code each one separately.

Example

The data set birthsmokers2.txt contains data on the birthweight (y = Wgt), gestation length (x1 = Gest) and mother's smoking status (x2 = Smokes, yes or no) of babies born to 32 mothers. If you wanted to fit a multiple regression model that included smoking status, you'd first have to create a numeric variable in your worksheet, dummy say, that equals 1 if Smokes = yes and equals 0 if Smokes = no. Create the dummy variable in your worksheet.

Minitab Dialog Box

dialog box

Resulting Minitab Worksheet

worksheet

Close this window when finished.

© 2004 The Pennsylvania State University. All rights reserved.
Materials developed by Dr. Laura J. Simon (Lecturer, Penn State Department of Statistics).