The SAS Output Delivery System and reporting techniques

Use Column Labels in export

Reply
N/A
Posts: 0

Use Column Labels in export

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".
SAS Super FREQ
Posts: 8,868

Re: Use Column Labels in export

Posted in reply to deleted_user
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
N/A
Posts: 0

Re: Use Column Labels in export

Posted in reply to Cynthia_sas
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
SAS Super FREQ
Posts: 8,868

Re: Use Column Labels in export

Posted in reply to deleted_user
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
Ask a Question
Discussion stats
  • 3 replies
  • 151 views
  • 0 likes
  • 2 in conversation