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 (November 2004, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 18 Nov 2004 19:28:08 -0500
Reply-To:   "Chang Y. Chung" <chang_y_chung@HOTMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Chang Y. Chung" <chang_y_chung@HOTMAIL.COM>
Subject:   Re: How to import an excel file with several sheets to SAS
Comments:   To: "Amy L. Sheng" <lhsheng_1@YAHOO.COM>

On Thu, 18 Nov 2004 11:12:12 -0500, L. Sheng <lhsheng_1@YAHOO.COM> wrote:

>I want to import the 4 sheets in one excel file to SAS. How can I do it >to create 4 sas data sets corresponding to each sheet in that excel file? > >Thank you.

Hi, L,

If you have ms office 2002 (aka office xp) or later with sas 9 or later, then the simplest way is to ods out the office xml file and let the excel deal with converting xml into work sheets.

Recently at NESUG2004, Vicent DelGobbo (si), presented a paper doing exactly this. The paper is available at: http://www.nesug.org/html/Proceedings/nesug04/io/io10.pdf

and here is my test code to create two worksheets in a file. Each proc print output goes to one sheet. The generated excel workbook can be seen at http://changchung.com/g/test_ExcelXP.xls .

HTH.

Cheers, Chang

<sasl:code sysver="9.1" sysscp="WIN">

%let pwd=%sysfunc(pathname(WORK)); %put NOTE: pwd=&pwd.; x cd "&pwd.";

ods listing close; /* close the listing destination, i.e. lst output */ ods results off; /* turn off the results window */

ods tagsets.excelXP file="test_ExcelXP.xls" path="&pwd.";

proc print data=sashelp.class; /* first sheet */ run;

proc print data=sashelp.class; /* second sheet */ run;

ods tagsets.excelXP close; ods results on; ods listing; </sasl:code>


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