LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 2002, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 23 May 2002 09:26:03 -0400
Reply-To:   john.hixon@KODAK.COM
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   john.hixon@KODAK.COM
Subject:   SAS to Excel with headers from labels
Comments:   To: robert.schechter@ASTRAZENECA.COM
Content-type:   text/plain; charset=us-ascii

From: John Hixon

<robert.schechter@ASTRAZENECA.COM> wrote

>Hi Gang,

>I thought I remember this came up before, but I have searched the archives >without success.

>I need to write an Excel spreadsheet and have the column headers be created >from the SAS variable labels. I'm using SAS version 8.

>TIA,

Robert,

You've recvd good suggestions already. Assuming you don't need to customize your Excel cells using DDE, here is a "quick and dirty" way to output to Excel.

* make dummy data, some with labels; data junk; array v{10}; input v1-v10; do j=1 to 25; do k=1 to 10; v(k)=j*v(k); end; output; end; label v1="Yadda One" v2="Yadda Two" v3="Yadda 3" v4="Yadda 4" v5="Yadda 5"; datalines; 1 2 3 4 5 6 7 8 9 10 ; run;

*output directly to xls file. This will start Excel right away (which can be annoying.) Another option is to write to an html file, then open it using Excel;

* this will make an excel sheet using variable names as headers;

ods html file='c:\temp\JunkNolabels.xls' style=SASweb; proc print data=junk; run;

* this will make an excel sheet using variable labels as headers;

ods html file='c:\temp\JunkWithlabels.xls' style=SASweb; proc print data=junk label; run; ods html close;

*HTH;

Best Regards,

John Hixon Eastman Kodak Company Rochester, NY USA


Back to: Top of message | Previous page | Main SAS-L page