全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
3457 4
2008-08-06

我要把一个文件夹中许多个比如.txt或.dbf文件合并读入到一个SAS文件中,

问题是若是有1千个上市公司的文件,文件名只是代码不同,当然这些代码不完全可以采用循环读取,因为怕有的代码是不存在的,如何写SAS程序读取这么多文件是比较快捷方便?

谢谢各位能够帮助一下。

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2008-8-8 06:40:00
You can first get the list of the directory and assign it to a macro variable. Then, you can use loops to read it.

The following code put the list of file into dataset - myfile.

%macro cr_dir(_mydir_, OUT =);
    %local rc myref;
    %let rc  =  %sysfunc( filename( myRef, . ));
    %let myRef  =  _%substr( &myRef, 2 );
    filename &myRef pipe "&_mydir_";
    data &out;
    infile &myRef truncover;
    input myfiles $char200.;
    run;
    filename &myRef ;
%mend cr_dir;

%cr_dir ( dir /b/s d:\Summer\*.sas  , out = myfile );

Proc print data = myfile; run;

Hope it helps
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2008-8-10 09:24:00
多谢兄弟了
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2008-8-10 17:12:00

可怎么搞的这个程序只把文件名字,而没有内容那

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2008-8-12 10:01:00
The code only helps you to get the file list. You need to write code to use the list to read in your file.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群