Stata Help: Indicator Variable Problem

#1
Hi guys, my problem is probably simple and just a matter of finding the right command.

I have hundreds of thousands of observations which all have one of 100 codes associated with them. I've gone through these 100 codes and classified them into just 5 broader categories. So in a separate dataset I have this:

Code-----Type
56----------1
32----------3
78----------1
23----------2
12----------2
09----------4
95----------5
.
.
.
(300 more lines of this)

Now I want to go back to my original dataset and basically write these commands:

generate type2 = 0
replace type2 = 1 if code==56
replace type2 = 3 if code==32
replace type2 = 1 if code==78
replace type2 = 2 if code==23
.
.
.
(300 more of these)

This is not feasible to do by hand, unfortunately.

The ultimate goal, if you can't tell from the code, is for each of my observations that has a code associated with it, it would also have a 'type'.

I would greatly appreciate any pointers in the right direction.

Regards,
bowser
 
Last edited: