楼主: zoumingwang2004
2488 5

[原创博文] 求助怎样将一个目录下的doc文件名与文件标题一一读出来! [推广有奖]

  • 1关注
  • 0粉丝

爱股票

已卖:890份资源

副教授

29%

还不是VIP/贵宾

-

威望
0
论坛币
19 个
通用积分
37.0417
学术水平
3 点
热心指数
0 点
信用等级
0 点
经验
1589 点
帖子
411
精华
0
在线时间
727 小时
注册时间
2006-4-3
最后登录
2024-11-14

楼主
zoumingwang2004 发表于 2011-8-4 15:20:04 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
怎样用SAS将一个目录下的doc文件名与文件标题一一读出来,谢谢!
二维码

扫码加我 拉你入群

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

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

关键词:DOC文件 文件名 doc

本帖被以下文库推荐

沙发
soporaeternus 发表于 2011-8-4 15:47:47
前者用pipe
类似
  1. filename xx pipe "dir e:\*.doc /b";
  2. data _null_;
  3.         infile xx;
  4.         input str:$100.;
  5.         put _all_;
  6. run;
复制代码
后者完全不会,坐等高人出现......
Let them be hard, but never unjust

藤椅
yugao1986 发表于 2011-8-4 19:49:10
首先对这个问题感兴趣,所以搜索了下相关资料,贴出来给点思路,以便楼下讨论。
  1. filename readdoc1 dde
  2. "winword|c:\n0321\sapa00321.doc!FirstListOfTitles"
  3.        notab;

  4. filename readdoc2 dde
  5. "winword|c:\n0321\sapa00321.doc!SecondListOfTitles"
  6.        notab;

  7.         data sasuser.titles1;
  8.         infile readdoc1 end=eof truncover;
  9.         input @1 title $char200.;
  10.         run;

  11.         data sasuser.titles2;
  12.         infile readdoc2 end=eof truncover;
  13.         input @1 title $char200.;
  14.         run;

  15. data sasuser.Titles_In_SAP;
  16. set sasuser.titles1
  17.      sasuser.titles2;
  18. if substr(title,1,2) in('14','16');
  19. first_space=index(title,' ');
  20. title_number=substr(title,1,first_space-1);
  21. title=substr(title,first_space+1);
  22. title=tranwrd(title,'Data Listing','Listing');
  23. title=tranwrd(title,'Subject ','Subjects');
  24. run;
  25. proc sort data=sasuser.Titles_In_SAP out=Titles_In_SAP;
  26. by title;
  27. run;

  28. data sasuser.Titles_In_Docs;
  29. set a00321_doc_titles;
  30. path="r:\products\efz\a00321\stat\analysis\info\deliverables\20011202
  31. - draft1\"||substr(filename,1,3)||'doc\';
  32. title=tranwrd(title,'Populatio','Population');
  33. title=tranwrd(title,'Data Listing','Listing');
  34. title=tranwrd(title,'Subject ','Subjects');

  35. run;

  36. proc sort data=sasuser.Titles_In_Docs  out=Titles_In_Docs;
  37. by title;
  38. run;


  39. data SAPonly
  40.      Docsonly
  41.      both;
  42. merge Titles_In_SAP(in=inSAP)
  43.       Titles_In_Docs(in=inDocs);
  44. by title;
  45. if inSAP & inDocs then output both;
  46. else if inSAP & ^ inDocs then output SAPonly;
  47. else if ^inSAP & inDocs then output Docsonly;
  48. run;
复制代码
三人行必有我师

板凳
KingZ_71 发表于 2011-8-5 09:26:40
用通道技术(pipe)
给你个例子参考吧 ,应该还要完善一下。在linux下命令要换一下的。
  1. filename f pipe "dir -R D:\base_tt\test";
  2. data resdat (drop = location name info msg);
  3.         length sasname $50.;
  4.         infile f ;
  5.         input name info msg sasname;
  6.         location = index(sasname,'.');
  7.         if substr(sasname,location+1) = 'sas7bdat';
  8.         sasname = substr(sasname,1,location-1);
  9. run;



  10. /*将sas代码写入临时文件集*/
  11. filename labelref catalog "work.C.sdb.source";
  12. filename SASRes pipe "dir -r D:\base_tt\test";
  13. data _null_;
  14. file labelref LRECL=500;

  15. str='data resdat (drop = location name info msg);';
  16. put str;
  17. str='length sasname $50.;';
  18. put str;
  19. str='infile SASRes;';
  20. put str;
  21. str='input name info msg sasname;';
  22. put str;
  23. str="location = index(sasname,'.');";
  24. put str;
  25. str='if substr(sasname,location+1) = "sas7bdat";';
  26. put str;
  27. str='sasname = substr(sasname,1,location-1);';
  28. put str;
  29. str='run;';
  30. put str;




  31. run;
  32. /*执行source中的sas code*/
  33. %include labelref /source;

  34. /*取消临时目录的引用*/
  35. filename labelref clear;
复制代码

报纸
KingZ_71 发表于 2011-8-5 09:26:48
上面两段分开

地板
zoumingwang2004 发表于 2011-8-5 09:31:22
谢谢各位,下来研究研究!

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

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