DATA Step, Macro, Functions and more

Macro to export sas dataset to Excel

Posts: 36

Macro to export sas dataset to Excel


Hi SAS Users,


I am converting SAS dataset to excel and I am using following code. but the issue is in excel the width is eneven (kindly see the screenshot which attached). kindly let me know where I need to update the code.

Note: I am using SAS EG 7.1 (64-bit).


ods listing close;
ods tagsets.excelxp
OPTIONS (Orientation = 'landscape'
embedded_titles = 'yes'
FitToPage = 'Yes'
Pages_FitWidth = '1'
Pages_FitLength = '100'
autofilter = 'all');
%let trans=;

Super User
Posts: 10,209

Re: Macro to export sas dataset to Excel

I guess your complaint is not about width, but height of cells.

Since this is basically free-form text, look for hidden linefeeds.

(convert the strings in the dataset to hexadecimal representation using the $HEXw. format to show special characters)

Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Super User
Super User
Posts: 9,599

Re: Macro to export sas dataset to Excel



There isn't enough information there, that is just the file open command.  What is your proc report doing?  What should the output look like?  What is this sas_xls style?

Super User
Posts: 23,663

Re: Macro to export sas dataset to Excel

Tagsets has a auto row height option as well as a skip space option. 

Have you tried those?


its unlikely but verify your running the latest tagsets version. 

The version is posted in your log after the ods statement and the latest version is on the download page. 

Ask a Question
Discussion stats
  • 3 replies
  • 4 in conversation