Dear All,
I have two concerns regarding the naming of the sheets in export to Excel.
1) First is that the $-sign is misinterpreted in the sheet name while exporting to Excel. Consider the following minimal example:
Note that while display command obeys escaping of a macro, the export command does not and the output is placed into the sheet named "sheet1" instead of "$data".
I believe that Stata conducts the macro expansion somewhere internally where it shouldn't, evaluating $data to an empty string (if everything is running in a clean session) or more dangerously to the value of the global named data, which may cause accidental overwriting of some useful data.
2) Second, I have further checked, whether Stata is, perhaps, removing the \-slash as the first action resulting in an un-escaped sheet name. It is not doing this, and the \-slash gets saved all the way, resulting in a corrupt Excel file (Excel offers to recover data from such a workbook, since the \-slash is not permitted in sheet names).
I wonder if these problems can be confirmed by a third party? whether they have been fixed in Stata 14.1? and what is the workaround for issue #1 in Stata 14.0?
Thank you,
Sergiy Radyakin
Stata 14.0MP/Windows
I have two concerns regarding the naming of the sheets in export to Excel.
1) First is that the $-sign is misinterpreted in the sheet name while exporting to Excel. Consider the following minimal example:
Code:
clear all version 14.0 display "\$data" sysuse auto export excel "C:\temp\testbug.xlsx" , replace firstrow(variables) sheet("\$data")
I believe that Stata conducts the macro expansion somewhere internally where it shouldn't, evaluating $data to an empty string (if everything is running in a clean session) or more dangerously to the value of the global named data, which may cause accidental overwriting of some useful data.
2) Second, I have further checked, whether Stata is, perhaps, removing the \-slash as the first action resulting in an un-escaped sheet name. It is not doing this, and the \-slash gets saved all the way, resulting in a corrupt Excel file (Excel offers to recover data from such a workbook, since the \-slash is not permitted in sheet names).
Code:
<?xml version="1.0" encoding="UTF-8"?>
<workbook xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
<workbookPr/>
<bookViews>
<workbookView activeTab="0"/>
</bookViews>
<sheets>
<sheet name="\data" sheetId="1" r:id="rId2"/>
</sheets><calcPr calcId="125725" fullCalcOnLoad="true"/>
</workbook>
I wonder if these problems can be confirmed by a third party? whether they have been fixed in Stata 14.1? and what is the workaround for issue #1 in Stata 14.0?
Thank you,
Sergiy Radyakin
Stata 14.0MP/Windows
Comment