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 (April 2001, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 16 Apr 2001 15:41:29 -0400
Reply-To:   Edward Heaton <HEATONE@WESTAT.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Edward Heaton <HEATONE@WESTAT.COM>
Subject:   Re: Loading a SAS Dataset to MS Excel w/ formatted cells?
Comments:   To: "Brittain, James" <zqr0@CDC.GOV>
Content-Type:   text/plain; charset="iso-8859-1"

James, We use ODS to HTML to accomplish this trick. We then import the *.htm file into Excel and the formatting comes relatively intact. You can use PROC TEMPLATE to make the HTML output look the way you want and then the Excel spreadsheet will retain those characteristics. E.g.

Data test ; Array var[5] ; Do i=1 to 20 ; Do j=1 to 5 ; var[j] = ranUni(76867168) ; End ; Output ; End ; Run ; Ods html file="C:\My Documents\SasTesting\test.html" ; Proc print data=test ; Run ; Ods html close ;

creates an html file called test.html. You can then open Excel and select OPEN from the FILE drop-down menu. Select Files of type: HTML Documents. Then open your file (test.html).

Is this close to what you want? Ed

Edward Heaton, SAS Senior Statistical Systems Analyst, Westat (An Employee-Owned Research Corporation), 1550 Research Boulevard, Room 2018, Rockville, MD 20850-3195 Voice: (301) 610-4818 Fax: (301) 294-3992 mailto:EdwardHeaton@westat.com http://www.westat.com

-----Original Message----- From: Brittain, James [mailto:zqr0@CDC.GOV] Sent: Monday, April 16, 2001 12:14 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Loading a SAS Dataset to MS Excel w/ formatted cells?

Is there a way to load data into a MS Excel spreadsheet and have control over the cell formatting, not the data formats, like BOLD, SHADING, and GRIDLINES?

I was have been loading data into Excel by either creating a .CSV file and opening it with Excel or directly creating .XLS using SAS/ACCESS DBLOAD procedure. The problem is that once I have the data in the spreadsheet I have to go in and format the cells the way I want them to look. Usually I add gridlines, make the labels bold, shade some cells, modify the width of columns, and change cells to "wrap text". There are times that I have to create multiple spreadsheets that need to look the same but have different data.

I was thinking that I could create an Excel template and call it with DBLOAD or create an empty spreadsheet the way I want it and APPEND to it but from what I understand APPEND is not available with the XLS DBMS in SAS/ACCESS. I would think that something along this line would be the idea because I do not see and SAS syntax for the DBLOAD procedure that allows for formatting the cells like (row_1 = BOLD, row_2 = NOBOLD).

Another thing that I noticed is when I use the DBLOAD procedure with long character variables it is truncating them to $200. Is this because the DBLOAD (.XLS) procedure has not been updated to the long character variables yet?

Thanks in advance for any and all help,

Jim Brittain


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