Recode reads the recoding scheme for codefile and applies it to the first column in the datafile.
The codefile contains two columns, oldcode and newcode (in that order).
The datafile is assumed to contain the old code as the first column.
The output consists of a new column, of the same name as the newcode column in codefile, and then the columns of the datafile.
Suppose the file recode.data contains the lines:
ex1 w y z v u extra --- - - - - - ----- 25 0 9 2 3 4 -3 4 0 2 2 3 4 -2 5 0 3 4 5 6 -3 5 2 3 4 6 7 -4 9 2 5 6 7 10 -3 9 2 5 6 120 8 -116 9 23 5 6 7 8 16 25 0 9 2 3 4 -3 25 2 9 2 5 6 -3And the code file recode.codes contains :
ex1 new --- --- 1 20 2 21 3 22 4 23 5 24 9 25 25 0The following is the output from the command recode recode.codes < recode.data
new ex1 w y z v u extra --- --- - - - - - ----- 0 25 0 9 2 3 4 -3 23 4 0 2 2 3 4 -2 24 5 0 3 4 5 6 -3 24 5 2 3 4 6 7 -4 25 9 2 5 6 7 10 -3 25 9 2 5 6 120 8 -116 25 9 23 5 6 7 8 16 0 25 0 9 2 3 4 -3 0 25 2 9 2 5 6 -3
There is a built-in limit on the magnitude of the old codes, as these are read into a hard-coded vector.