如何用SAS读取EXCEL文件SAS论坛
在C盘新建了一个名为book.xls的EXCEL文件,文件内容:
现在把用SAS读取它,我们有以下几种途径(还有一些,待学):
1.LIBNAME STATEMENT
libname xlsfile 'c:/book.xls' mixed=no header=yes scantime=yes ;
/*mixed,是否将数值型变量转化为字符型变量*/
/*header,是否将excel中数据第一行设为sas型数据变量名*/
/*scantime,是否遍历查询日期型数据,自动设置日期数据的格式*/
2.PROC SQL PASS-THROUGH FACILITY
proc sql;
connect to excel (path="c:/book.xls");
create table book as
select *
from connection to excel (select * from [sheet1$]);
disconnect from excel;
quit;
3.IMPORT PROCEDURE
PROC IMPORT OUT= WORK.BOOK1
DATAFILE= "C:/Book.xls"
DBMS=EXCEL REPLACE;
RANGE="Sheet1$";
GETNAMES=YES;
MIXED=NO;
SCANTEXT=YES;
USEDATE=YES;
SCANTIME=YES;
RUN;