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

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

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