I wanna replicate the results of this paper. Consider their dataset
As we can see, the esteemed authors for some unknown reason left the dataset wide and didn't bother to give the columns meaningful names. The names of the provinces themselves, the units of interest, are in this file
Here's what I want:
I want to rename each of the columns from the first dataset (v2-v32) to something like province_Beijing .... and so on and so forth.
However, I do not want to have to do
I want to automate the renaming, such that the variables from the first dataset are renamed with the values (in order) of the second dataset so that I may reshape it and get down to business.
How might I do this? My initial thought was levelsof, but that orders it alphabetically, which would mess up the names. Would there be a better, more efficient way of renaming the variables from my first dataset so that I can reshape it?
Code:
copy "http://qed.econ.queensu.ca/jae/datasets/ke001/kh-data.zip" "kh-data.zip", replace qui unzipfile kh-data.zip, replace erase kh-data.zip import delimited "kh-data.txt", clear
Code:
import delimited "http://qed.econ.queensu.ca/jae/datasets/ke001/readme.kh.txt", rowrange(45:75) clear delim(")")
I want to rename each of the columns from the first dataset (v2-v32) to something like province_Beijing .... and so on and so forth.
However, I do not want to have to do
Code:
rename (v1 v2) (province_Beijing province_Tianjin) //.... and so on.
How might I do this? My initial thought was levelsof, but that orders it alphabetically, which would mess up the names. Would there be a better, more efficient way of renaming the variables from my first dataset so that I can reshape it?

Comment