Hello,
I am working on a dataset that consists of a key string variable (MAST chapter) that refers to trade policy eg. (sanitary and phytosanitary measures). I need to reshape my data set and count every one of them. My problem is how to name the new variables, I need to rename them because they have space, etc.. I use commands such as (following commands work very well)
replace MASTchapter = strtoname(MASTchapter)
or
replace MASTchapter = subinstr(MASTchapter, " ", "", .)
to turn them into workable names is Stata. However, when I want to reshape my dataset by
reshape wide count, i(id) j(MASTchapter) string
rename count* *
STATA returns
countA_Sanitary_and_phytosanitary_m invalid variable name
I know that these names are very long (more than 31 characters) and I need to modify them. Since my dataset is very large, I am looking for a smart way to do it other than just replacing every one of them with new names. Is there any solution to this problem?
Thanks for the support.
I am working on a dataset that consists of a key string variable (MAST chapter) that refers to trade policy eg. (sanitary and phytosanitary measures). I need to reshape my data set and count every one of them. My problem is how to name the new variables, I need to rename them because they have space, etc.. I use commands such as (following commands work very well)
replace MASTchapter = strtoname(MASTchapter)
or
replace MASTchapter = subinstr(MASTchapter, " ", "", .)
to turn them into workable names is Stata. However, when I want to reshape my dataset by
reshape wide count, i(id) j(MASTchapter) string
rename count* *
STATA returns
countA_Sanitary_and_phytosanitary_m invalid variable name
I know that these names are very long (more than 31 characters) and I need to modify them. Since my dataset is very large, I am looking for a smart way to do it other than just replacing every one of them with new names. Is there any solution to this problem?
Thanks for the support.
Comment