I got a spreadsheet with its first row contains the variable names and second row contains the corresponding descriptions like:
A B C
GDP UEM RATE
gross domestic product unemployment rate one year coupon bond rate
Importing the data into Stata, we can easily use the option firstrow to tell Stata taking first row as variable names. However, as the second line contains all the detailed description words of that variable, including them into variable label is of great significance. Initally, I wrote the following code:
Code:
clear all
import excel myData.xlsx, firstrow
foreach var of varlist *{
      label variable `var' `var'[1]
}
drop in 1 
foreach var of varlist*{
      destring `var', replace
}
save myData.dta
But Stata told me there was a "invalid syntax" and I modified the forth line with a double quotation:
Code:
label variable `var' "`var'[1]"
Unfortunately, all the variables' labels became "varname[1]" form. So I checked help file of label and then I realized that "label variable varname labeltext" command just treats labeltext as a string whatever with a double quotation or not, it seems that reference is inavailable.
Is there any solution to this problem? Converting information into label merely by keyboard entering is demanding! Thanks!