I am trying to bring some data into a different format. The data is World Uncertainty Index, which is publicly available for research purposes (https://worlduncertaintyindex.com/). The data provided is in the format that doesn't fit my overall dataset with other variables, so I've been trying to reshape it but no luck.
Current data format is
Period | AFG | AGO | ALB | ARE |
2009q1 | var1 value | var1 value | var1 value | var1 value |
2009q2 | var1 value | var1 value | var1 value | var1 value |
2009q3 | var1 value | var1 value | var1 value | var1 value |
2009q4 | var1 value | var1 value | var1 value | var1 value |
What I am trying to get is as follows:
Country | Period | Var1 |
AFG | 2009q1 | value |
AFG | 2009q2 | value |
AFG | 2009q3 | value |
AFG | 2009q4 | value |
ARE | 2009q1 | value |
ARE | 2009q2 | value |
ARE | 2009q3 | value |
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str6 year byte(AFG AGO) double ALB byte ARE double ARG byte ARM double AUS "1952q1" . . . . 1 . 0 "1952q2" . . . . 0 . 2 "1952q3" . . . . 0 . 0 "1952q4" . . . . 0 . 0 "1953q1" . . . . 0 . 1 "1953q2" . . . . 0 . 2 "1953q3" . . . . 0 . 0 "1953q4" . . . . 1 . 0 "1954q1" . . . . 1.5 . 0 "1954q2" . . . . 2 . 2 "1954q3" . . . . 0 . 2 "1954q4" . . . . 0 . 2 "1955q1" . . . . 2 . 1 "1955q2" . . . . 0 . 0 "1955q3" . . . . 1 . 3 "1955q4" . . . . 1 . 5 "1956q1" 0 . 0 . 0 . 0 "1956q2" 0 . 0 . 0 . 2 "1956q3" 0 . 0 . 1 . 2 "1956q4" 0 . 1 . 2 . 2 "1957q1" 0 . .5 . 0 . 0 "1957q2" 0 . 0 . 0 . .66666667 "1957q3" 0 . 0 . 0 . 1.3333333 "1957q4" 0 . 0 . 0 . 2 "1958q1" 1 . 0 . 0 . 1 "1958q2" 0 . 0 . 0 . 1 "1958q3" 0 . 0 . 1 . 3 "1958q4" 0 . 0 . 1 . 1 "1959q1" 0 . 0 . 0 . 0 "1959q2" 0 . 0 . 0 . 0 "1959q3" 0 . 0 . 0 . 0 "1959q4" 0 .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" 0 . 0 1 3 . 3 "1972q2" 0 . 0 0 3 . 0 "1972q3" 0 . 0 0 4 . 3 "1972q4" 0 . 0 0 1 . 0 "1973q1" 0 . 1 0 3 . 2 "1973q2" 0 . 0 0 2 . 8 "1973q3" 0 . 0 1 1 . 2 "1973q4" 0 . 0 0 3 . 1 "1974q1" 3 0 0 1 1 . 0 "1974q2" 0 0 0 0 1 . 0 "1974q3" 0 0 0 0 3 . 2 "1974q4" 0 1 0 0 3 . 3 "1975q1" 0 0 0 0 1 . 0 "1975q2" 0 0 0 0 2 . 2 "1975q3" 0 0 0 0 0 . 2 "1975q4" 0 0 0 0 1 . 1 "1976q1" 0 0 0 0 1 . 0 "1976q2" 0 0 0 0 2 . 2 "1976q3" 0 1 1 0 0 . 0 "1976q4" 0 2 0 0 1 . 2 end
0 Response to Help with reshaping the data
Post a Comment