【发布时间】:2016-03-24 15:23:44
【问题描述】:
我正在使用 SAS 9.3 对几个 CSV 数据集进行一些分析。 我正在寻找自动加载对 SAS 说的文件 查看特定目录并加载到单独的数据集每个文件。
我是 SAS 编码的新手,如果我忽略了一些重要的点,请原谅我。
我要使用的代码是这样的:
filename filelist pipe 'dir "C:\my_path\*.csv" /b';
data file_list ; *** here I have the list of files to be read
length file_name $256 ;
infile filelist length=reclen ;
input file_name $varying256. reclen ;
run;
*** HERE I MISS HOW TO DYNAMICALLY LOAD A NUMBER OF FILES NOT KNOWN BEFORE;
*** I should find a way to say: set file_list;
proc import datafile="C:\my_path\"||file_name; *** I know that in this way doesn't work but It was just to show my idea of doing it.
out = file_name
dbms = csv
replace;
getnames = yes;
run;
非常感谢您的帮助! 请随时完全编辑解决此任务的方法。
收到建议后,我修改了代码,但还是不行……
filename filelist pipe 'dir "C:\my_path\*.csv" /b';
data file_list ; *** here I have the list of files to be read
length file_name $256 ;
infile filelist length=reclen ;
input file_name $varying256. reclen ;
run;
%MACRO load_my_csv_file(name_file=);
proc import datafile="C:\my_path\"||&name_file
out = &name_file
dbms = csv
replace;
getnames = yes;
run;
%MEND load_my_csv_file;
data _NULL_ ;
set file_list;
call execute('%load_my_csv_file(name_file='||file_name||')');
run;
但它不起作用!
【问题讨论】:
-
不工作到底是什么意思?
标签: sas