NOTE: Libref EXCELLIB was successfully assigned as follows:
Engine: EXCEL
Physical Name: C:\sasCode\abc.xls
NOTE: The query as specified involves ordering by an item that doesn't appear in its SELECT clause.
NOTE: Table WORK.SHEETNAME created, with 0 rows and 1 columns.
WARNING: INTO Clause :sheet1 thru :sheet0 does not specify a valid sequence of macro variables.
NOTE: No rows were selected.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.29 seconds
cpu time 0.03 seconds
NOTE: Libref EXCELLIB has been deassigned.
WARNING: Apparent symbolic reference CNT_SHT not resolved.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition
was: &cnt_sht
ERROR: The %TO value of the %DO I loop is invalid.
ERROR: The macro READXLS will stop executing.
阅读代码后,感觉是下面一段有问题
[code:2skz1h5f]
libname excellib excel "&dir.\&name";
proc sql noprint;
create table sheetname as
select tranwrd(memname, "''", "'" ) as sheetname
from sashelp.vstabvw
where libname= "EXCELLIB";
[/code:2skz1h5f]
其实,我对
from sashelp.vstabvw
where libname= "EXCELLIB";
不了解,感觉很可能是不对的,所以向大家请教,恳请您们帮忙。
如果有别的导入方式,请告诉我一下,非常感谢。作者: shiyiming 时间: 2012-6-14 01:21 标题: Re: excel中的所有sheet导入sas 首先,你的文件中可能没有合法的表名,造成啥名字也没有选出来。
另外,好像你把宏变量名弄错了。select count(DISTINCT sheetname) into :number,后面用的是 &cnt_sht, but &number;
再:EXCLE每个表会产生两名子,其中一个名字以$结尾,另一个没$.
试一下这段代码:
%macro test;
proc sql noprint;
select memname into: names separated by ' '
from sashelp.vstable
where libname= "EXCELLIT" and memname not like '%$';
quit;
%let cnt_sht=&sqlobs;
data master;
set
%do i=1 %to &cnt_sht;
%let memn=%scan(&names,&i);
excellit.&memn
%end;
;
run;
%mend;