Hi all,
I have a dta file with data set as :
fid year tbl_2001 tbl_2002 tbl_2003 tbl_2004 tbl_2005
2 2001 5 7 9 3 2
2 2002 5 7 9 3 2
2 2003 5 7 9 3 2
2 2004 5 7 9 3 2
2 2005 5 7 9 3 2
5 2001 6 1 8 4 3
5 2002 6 1 8 4 3
5 2003 6 1 8 4 3
5 2004 6 1 8 4 3
5 2005 6 1 8 4 3
7 2001 0 3 7 9 1
7 2002 0 3 7 9 1
7 2003 0 3 7 9 1
7 2004 0 3 7 9 1
7 2005 0 3 7 9 1
And I want to create a new variable “tbl” to replace variables (tbl_2001 tbl_2005) as the following data set :
fid year tbl
2 2001 5
2 2002 7
2 2003 9
2 2004 3
2 2005 2
5 2001 6
5 2002 1
5 2003 8
5 2004 4
5 2005 3
7 2001 0
7 2002 3
7 2003 7
7 2004 9
7 2005 1
- How can I get the value of year via the position of variable such as year[1] = 2001, year [2] =2002
- Do you have any suggestions to change the data set?
Thank you in advance.
Hut98
Related Posts with Create a new variable to combine the value of other variables
Speeding up Mixlogit with large datasetsHi there, I am running a mixed logit model using the user written command mixlogit on Stata 16/MP8 …
Clustering of SEs: Heteroskedasticity and AutocorrelationI am running a panel data analysis of geographic diversification (quadratic) on company performance …
Running regression including fixed effects and clustered standard errorsHello everyone, i have panel data on a monthly basis over a time span of 14 years for 26 cities. Si…
How to make twoway line graph over group in the same figureHello colleagues, How can I make twoway line graph across grouping variable on the same figure? For…
Is there any other wrapper/executer/(executioner?) apart from -rangestat- that can run Mata functions?Good morning, I recently discovered a nice feature of the user contributed -rangestat-: one can use…
Subscribe to:
Post Comments (Atom)
0 Response to Create a new variable to combine the value of other variables
Post a Comment