SAS计数优秀的意见

我必须对excel文件进​​行大约500个excel文件的核对。

我不需要通过文件来匹配帐户号码。

Example file 1: \\directory\Loaded\Jan2014\excel1 Example file 2: \\directory\Loaded\Feb2014\excel2 Example file 3: \\directory\Loaded\Feb2014\excel3 

(帐号始终填充在B列中,第1到第5行作为标题)

使用上面的例子需要输出:

主文件夹(文件)| 子文件夹(Jan2014)| 文件名(excel1)| 帐号数量

这可能使用SAS吗?

所以如果这些信息不够,我已经search了networking,并find了使用batch file恢复文件列表的方法,但没有任何数据可以反映观察结果。

SAS解决scheme就是这样的。 如果你完成所有的libnames,然后设置所有的数据集,那么你可以使它更高效一些,但是这个代码更简单一些,对于500我觉得这是合理的。 不幸的是,excel libnames似乎没有为你排好序,所以你不能只使用dictionary.tables来做到这一点。

如果工作表名称有所不同,则需要修改此选项以考虑这一点,或者通过设置一个macrosvariables来保存工作表名称,如果以某种方式链接到文件名,或者让macros执行一个查询dictionary.tables以查看libname中存在的表。

 %let basedir=c:\temp; *whatever the base directory is that all of your excel files are upstream from; filename dirl pipe "dir /b/s &basedir.\*.xlsx"; data libnames; infile dirl lrecl=1024 pad; input @1 filename $1024.; run; %macro get_rowcount(file=); libname _temp excel "&file."; data _rowcount; set _temp."Sheet1$"n end=eof; length file_name $1024; retain file_name "&file."; if eof then do; rowcount=_n_; output; end; keep rowcount file_name; run; proc append base=rowcounts data=_rowcount force; run; %mend get_rowcount; proc sql; select cats('%get_rowcount(file=',filename,')') into :sheetlist separated by ' ' from libnames; quit; &sheetlist.; 

我会使用Powershell,除非你真的需要在SAS中完成。 为了得到SAS的结果,如果需要的话,可以将数据从powershell保存到excel文件并导入到SAS。

看看例如Get工作表的列的行数作为起动器。