2
我有一堆csv文件。每个人都有不同时期的数据:在SAS中追加csv文件
filename file1 'JAN2011_PRICE.csv';
filename file2 'FEB2011_PRICE.csv';
...
是否需要手动创建中间数据集,然后将它们全部附加在一起?有没有更好的方法来做到这一点?
SOLUTION
从它是优选使用的文档:
data allcsv;
length fileloc myinfile $ 300;
input fileloc $ ; /* read instream data */
/* The INFILE statement closes the current file
and opens a new one if FILELOC changes value
when INFILE executes */
infile my filevar=fileloc
filename=myinfile end=done dlm=',';
/* DONE set to 1 when last input record read */
do while(not done);
/* Read all input records from the currently */
/* opened input file */
input col1 col2 col3 ...;
output;
end;
put 'Finished reading ' myinfile=;
datalines;
path-to-file1
path-to-file2
...
run;
我喜欢上述方式,因为它不需要文件在一个目录中。但是,如果所有人都在一个地方,这很好。 – 2011-02-10 14:07:35