楼主: hippocrene
3492 4

[求助]如何读取多个外部文件? [推广有奖]

  • 0关注
  • 0粉丝

本科生

53%

还不是VIP/贵宾

-

威望
0
论坛币
30785 个
通用积分
1.4500
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
1606 点
帖子
53
精华
0
在线时间
141 小时
注册时间
2005-9-15
最后登录
2024-3-26

楼主
hippocrene 发表于 2008-8-6 15:28:00 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

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

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

谢谢各位能够帮助一下。

二维码

扫码加我 拉你入群

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

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

关键词:sas程序 dbf文件 文件合并 上市公司 文件夹 文件

回帖推荐

SignPingGu 发表于2楼  查看完整内容

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 );   ...

本帖被以下文库推荐

沙发
SignPingGu 发表于 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
已有 1 人评分经验 论坛币 收起 理由
bakoll + 3 + 3 精彩帖子

总评分: 经验 + 3  论坛币 + 3   查看全部评分

藤椅
爱萌 发表于 2008-8-10 09:24:00
多谢兄弟了
最恨对我说谎或欺骗我的人

板凳
爱萌 发表于 2008-8-10 17:12:00

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

最恨对我说谎或欺骗我的人

报纸
SignPingGu 发表于 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.

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-29 17:22