Desktop productivity for business analysts and programmers

How to preserve the format while exporting a Dataset into Excel 2010 xlsx

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 119
Accepted Solution

How to preserve the format while exporting a Dataset into Excel 2010 xlsx

Hello,

 

I would like to know  if there is a sample way to preserve the dataset format while exporting the output results from SAS to an xlsx file.

Please note that I am using proc export.

 

%macro Export2;
proc export
data=Final
dbms=xlsx
outfile="\\iagsrvfic01\report.xlsx"
replace;
sheet=Rate;
run;
%mend Export2;

%Export2;

 

I have tried ODS Tagset.ExcelXP but I received an error message due to the Excel format file (xlsx instead of xls)

ODS Tagset.ExcelXP file="\\iagsrvfic01\report.xlsx" ;

PROC PRINT DATA=Final;
VAR var1 var2 var3;
VAR var4 var5 / style={TAGATTR='format:0.00'};
RUN;
ODS tagsets.ExcelXP CLOSE;

 

Regards,

 


Accepted Solutions
Solution
2 weeks ago
Super User
Super User
Posts: 9,465

Re: How to preserve the format while exporting a Dataset into Excel 2010 xlsx

No, proc export is a basic dump of the data. 

Use ods tagsets.excelxp, which can create nice outputs.  The thing you get is not an error, it is a warning from Excel.  It is telling you that the file you have - the output from the tagsets - is XML, yet you have given it the file extension XLSX.  So Excel is telling you that this does not match.  It is again, not an error, its it perfectly understandable.  Call the output file xml, and then open it with Excel (not double click on it which will defaut to opening with browser).  The file extension is important, and this tells programs what the file is.

 

Or use the newer one ods excel:

http://documentation.sas.com/?docsetId=odsug&docsetTarget=p09n5pw9ol0897n1qe04zeur27rv.htm&docsetVer...

Which creates actual xlsx files, but you have to have a recent SAS version.

 

 

View solution in original post


All Replies
Solution
2 weeks ago
Super User
Super User
Posts: 9,465

Re: How to preserve the format while exporting a Dataset into Excel 2010 xlsx

No, proc export is a basic dump of the data. 

Use ods tagsets.excelxp, which can create nice outputs.  The thing you get is not an error, it is a warning from Excel.  It is telling you that the file you have - the output from the tagsets - is XML, yet you have given it the file extension XLSX.  So Excel is telling you that this does not match.  It is again, not an error, its it perfectly understandable.  Call the output file xml, and then open it with Excel (not double click on it which will defaut to opening with browser).  The file extension is important, and this tells programs what the file is.

 

Or use the newer one ods excel:

http://documentation.sas.com/?docsetId=odsug&docsetTarget=p09n5pw9ol0897n1qe04zeur27rv.htm&docsetVer...

Which creates actual xlsx files, but you have to have a recent SAS version.

 

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 123 views
  • 0 likes
  • 2 in conversation