I have 3 variables in Stata that I want to make into a panel variable, f4hi. Currently, they are called f4hi97, f4hi98, and f4hi99. I want to pull the last two digits from these to create a separate year variable (1997, 1998, and 1999).
The image shows the way I want the data to look.
I have tried this command to reshape to panel, but it will not work without the year variable
reshape long f4hi97 f4hi98 f4hi99, i(id) j(year)
Ultimately, I want to be able to run this model:
xtreg f4hi99 f2s99d race sex byfaminc byt3_8, fe
It's a common error to supply
reshape longwith variable names. It needs stubnames. Alsoj()indicates a variable that will be created, not a variable in your dataset at present. You might try