BookmarkSubscribeRSS Feed
Bill
Quartz | Level 8
I currently produce a report using ods html to produce a file that excel is able to open. We have a number of users that only have excel viewer - which is unable to open an ods html or ods csv produced file. While proc export will work, I want to use labels instead of variable names, hence the ods method.

Is there an ods method that I can use to produce excel viewer readable files?
Or some other option?
Using SAS 9.1.3 on Windows.

Thanks,
wd
2 REPLIES 2
Cynthia_sas
SAS Super FREQ
Hi:
When I use the Excel Viewer to open files, the only supported file types are:
*.xlsx, *.xlsm, *.xlsb, *.xltx; *.xltm, *.xls, *.xlt, *.xml, *.xlw

Since ODS does not create "true" Excel files -- it only creates ASCII-text HTML or XML or CSV files -- that means that ODS output will not be openable in the Excel Viewer. If you try to "fool" the Windows registry by giving the ODS output an extension of .XLS, you can open the ODS file with Excel, but NOT with the Excel Viewer -- the Viewer knows that the real content of the file is HTML or XML or CSV and the Viewer will not open the file.

So you have a few choices:
1) create your ODS output from PROC REPORT and run a VB script to "resave" the file to a "true" Excel .XLSX or .XLS format or .XLSB format so the resaved file can be opened in the Excel Viewer. This approach would also preserve the colors, fonts and titles used for the ODS output.;
OR
2) If you have SAS/Access to PC file formats, try this code (it worked for me in 9.2 -- not sure whether PUTNAMES was available in 9.1):
[pre]

data class;
set sashelp.class(obs=3);
label name = 'Koala'
age = 'The Age';
run;

proc export data=class
file='c:\temp\class.xls'
dbms=xls replace label;
putnames=yes;
run;
[/pre]

when I run this form of PROC EXPORT, I can use the PUTNAMES=YES option with the LABEL option to write the labels (so I see Koala and The Age) in the Excel Viewer when I open the file. If there is no label specified for a variable, then the variable name is used in the output file. PUTNAMES is described on page 44-45 of the documentation:
http://support.sas.com/documentation/cdl/en/acpcref/63184/PDF/default/acpcref.pdf

There's also a discussion of the difference between DBMS=XLS and DBMS=Excel for PROC EXPORT in the doc -- PUTNAMES only works with DBMS=XLS for Excel files.

cynthia
Bill
Quartz | Level 8
Thanks Cynthia;

SAS 9.1.3 does not support your novel ideas. For now at least, the users will have to live with variable names via prod export.

wd

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 928 views
  • 0 likes
  • 2 in conversation