Stata is wonderful at this sort of thing, it's a simple reshape
. Your data is a little awkward, as the reshape
command was designed to work with variables where the common part of the variable name (in your case, Wage) comes first. In the documentation for reshape
, "Wage" would be the stub. The part following Wage is required to be numeric. If you first sort your variable names by
rename (raceWhiteWage raceBlackWage raceAsianWage) (Wage1 Wage2 Wage3)
Then you can do:
reshape long Wage, i(state year) j(race)
That should give you the output your are looking for. You will have a column labeled "race", with values of 1 for White, 2 for Black, and 3 for Asian.