Hi everybody,
I'm performing a simple task of importing xls data into stata. But the long name in the raw data is really giving me a hard time.
For illustration purpose, suppose I have three excel files CBA2001.xls, CBA2002.xls, CBA2003.xls with the same column name "Deal Value (Local Currency) Current". I'm using stata12.1. The code is simply
forval i = 2001/2003 {
import excel CBA`i', sheet("Sheet1") firstrow allstring clear
save CBA`i'
}
Taking a look at the dta files, i find the variable in CBA2001 is named DealValueLocalCurrencyCurre, which is 27 characters long. Ideally I'd like it goes up to the 32 characters limit. I have many similar variables in each data set. It is more likely to distinguish among these similar variables with more characters included in the name .
In CBA2002, the variable is called DealValueLocalCurrencyCurreP. In CBA2003, it is DealValueLocalCurrencyCurre0b. Why is the same code naming the same variable differently? This is causing trouble in my later append process.
I understand people normally don't work with such long variable names. But having hundreds of variables makes change the variable names before importing to stata a lot of labor. Anybody have any idea about this, please help. Thanks in advance.
Cheers,
Daisy Huang
I'm performing a simple task of importing xls data into stata. But the long name in the raw data is really giving me a hard time.
For illustration purpose, suppose I have three excel files CBA2001.xls, CBA2002.xls, CBA2003.xls with the same column name "Deal Value (Local Currency) Current". I'm using stata12.1. The code is simply
forval i = 2001/2003 {
import excel CBA`i', sheet("Sheet1") firstrow allstring clear
save CBA`i'
}
Taking a look at the dta files, i find the variable in CBA2001 is named DealValueLocalCurrencyCurre, which is 27 characters long. Ideally I'd like it goes up to the 32 characters limit. I have many similar variables in each data set. It is more likely to distinguish among these similar variables with more characters included in the name .
In CBA2002, the variable is called DealValueLocalCurrencyCurreP. In CBA2003, it is DealValueLocalCurrencyCurre0b. Why is the same code naming the same variable differently? This is causing trouble in my later append process.
I understand people normally don't work with such long variable names. But having hundreds of variables makes change the variable names before importing to stata a lot of labor. Anybody have any idea about this, please help. Thanks in advance.
Cheers,
Daisy Huang
Comment