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
SAS Super FREQ
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
SAS Super FREQ
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-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
  • 3 replies
  • 932 views
  • 0 likes
  • 2 in conversation