BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I am trying to export to excel and I want to use the column labels in the output to Excel. Can anyone tell me how to do this preferably with PROC EXPORT?

example "Member_ID" exported to Excel like "Member Id".
3 REPLIES 3
Cynthia_sas
Diamond | Level 26
Hi:
Sadly, according to the documentation, PROC EXPORT does not support writing labels as column names. Instead, try one of these techniques: ODS CSV or ODS HTML (or ODS MSOFFICE2K) to export (or even ODS EXCELXP):

[pre]
ods csv file='c:\temp\class.csv';
ods msoffice2k(1) file='c:\temp\class.html' style=minimal;
ods msoffice2k(2) file='c:\temp\class2.xls' style=minimal;
ods tagsets.excelxp file='c:\temp\class_xp.xls' style=minimal;

proc print data=sashelp.class label;
var name age height;
label name = 'Wombat'
age = 'Koala'
height = 'Armadillo';
run;

ods _all_ close;
[/pre]

cynthia
deleted_user
Not applicable
Hey Cynthia, that did the trick however now when I print to Excel it drops the leading 0's.

For example Member ID = 00001234
Now it shows as Member ID = 1234

I still need the 0's to show, any ideas? Message was edited by: kmgreen
Cynthia_sas
Diamond | Level 26
Hi:
Not with ODS CSV -- but with HTML or ExcelXP, you have to use a MICROSOFT format for the number. See these previous forum postings:
http://support.sas.com/forums/thread.jspa?messageID=1833ܩ
http://support.sas.com/forums/thread.jspa?messageID=3664๐

Since it involves, in some cases, using ODS style attributes and creating an updated tagset, you might want to contact Tech Support for more help with this.

cynthia

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1536 views
  • 0 likes
  • 2 in conversation