STATA help with variable renaming!


New Member
Hello stata crew,

I've encountered a peculiar problem and can't find a good fix. In short, I'm running surveys, exporting the data to excel, and then appending to my stata master file on a regular basis using insheet or the import function (I'm using stata 12). I do this on a weekly basis and have had no problems. Until now. I just installed office365 and was greeting with the following message when I tried to import the latest excel file:

Unable to load excel file
Error: Mandatory element missing

A quick google search shows that a few other people have had this issue, but no one reports a fix.

No problem, I though, I'll either save as a comma delineated file or copy and paste into data editor. Both get the data into stata, but both have the same problem -- when I specify that the first line of data should be saved as variable names, all of the variables names are changed to lower case. In my original data set, first letter of variables are capitalized, the rest is lower case (ex: Bio1). This means that I can't append the data sets, because the variable names don't match (stata saves Bio1 as bio1).

I have several hundred columns (due to the way qualtrics handles survey experiments and randomization), so renaming each variable by hand would take a long really long time, and I'd need to do it each time I import new data. So, two questions:

1. Any idea why I can't import the excel file properly anymore? I can't find an explanation for the problem either.
2. Any idea how I can import the data manually (copy and paste or csv), but keep stata from changing the variable names to all lower case?

Really appreciate any help! I'm far away from the office at the moment, so there are no doors for me to knock on!


For (1) I would suggest contacting Stata technical support. In all likelihood they will want to know about this problem and will fix it.

For (2) you could try using -insheet- with the case option, or you could import the data and then rename the variables:
rename *, proper
(see -help rename group-)
unable to import multiple excel sheets into STATA12

Hi everybody,

I am having issues when I try to import multiple excel sheets (office365) into STATA12. The software is showing the following message: "unable to load excel file; Error : mandatory element missing"

I have see few similar queries, but were unanswered.Has anyone managed to find a solution?

It will be great to have your thoughts!

Many thanks



As with the original post, I suggest contacting Stata technical support. If you post the file here I can take a look and see if I can figure something out.


New Member

I have been running into the same problem. You could fix this by saving the excel-files that you want to upload as an Excel 97-2003 Workbook. This way, Stata did not run the error anymore. I hope this works for you, too!