楼主: bobguy
1713 2

[程序分享] write all sas sample program(object) names in sasproduct sample folder into log [推广有奖]

学科带头人

7%

还不是VIP/贵宾

-

威望
0
论坛币
14187 个
通用积分
28.9279
学术水平
344 点
热心指数
363 点
信用等级
228 点
经验
104882 点
帖子
1846
精华
0
在线时间
1608 小时
注册时间
2008-7-18
最后登录
2019-3-8

中级热心勋章

楼主
bobguy 发表于 2013-3-11 02:11:12 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
The purpose is as in title.

options cmplib=sasuser.funcs;
proc fcmp outlib=sasuser.funcs.dir;

function diropen(dir $);
   length dir $ 256 fref $ 8;
   rc = filename(fref, dir);
   if rc = 0 then do;
      did = dopen(fref);
      rc = filename(fref);
   end;
   else do;
      msg = sysmsg();
      put msg '(DIROPEN(' dir= ')';
      did = .;
   end;
   return(did);
endsub;

subroutine dirclose(did);
   outargs did;
   rc = dclose(did);
   did = .;
endsub;

subroutine dir_entries(dir $, files[*] $, n, trunc);
   outargs files, n, trunc;
   length dir entry $ 256;

   if trunc then return;

   did = diropen(dir);
   if did <= 0 then return;

   dnum = dnum(did);
   do i = 1 to dnum;
      entry = dread(did, i);
      /* If this entry is a file, then add to array */
      /* Else entry is a directory, recurse. */
      fid = mopen(did, entry);
      entry = trim(dir) || '\' || entry;
      if fid > 0 then do;
         rc = fclose(fid);
         if n < dim(files) then do;
            trunc = 0;
            n = n + 1;
            files[n] = entry;
         end;
         else do;
            trunc = 1;
            call dirclose(did);
            return;
         end;
      end;
      else
         call dir_entries(entry, files, n, trunc);
   end;

   call dirclose(did);
endsub;
run;


*%let prod=access;
*%let prod=iml;
%let prod=core;

data _null_;
   array files[1000] $ 256 _temporary_;
   dnum = 0;
   trunc = 0;
   call dir_entries("%sysget(sasroot)\&prod.\sample", files, dnum, trunc);
   if trunc then put 'ERROR: Not enough result array entries. Increase array
size.';
   do i = 1 to dnum;
      put files[i];
   end;
run;

**********************************************;
C:\Program Files\SASHome\x86\SASFoundation\9.3\core\sample\append.sas
C:\Program Files\SASHome\x86\SASFoundation\9.3\core\sample\armsamp.sas
C:\Program Files\SASHome\x86\SASFoundation\9.3\core\sample\biorythm.sas
C:\Program Files\SASHome\x86\SASFoundation\9.3\core\sample\bpg01r01.sas
C:\Program Files\SASHome\x86\SASFoundation\9.3\core\sample\bpg02r01.sas
C:\Program Files\SASHome\x86\SASFoundation\9.3\core\sample\bpg05r01.sas
C:\Program Files\SASHome\x86\SASFoundation\9.3\core\sample\bpg07r01.sas
.........................
SNIPPED
.........................
C:\Program Files\SASHome\x86\SASFoundation\9.3\core\sample\univar2.sas
C:\Program Files\SASHome\x86\SASFoundation\9.3\core\sample\univar3.sas
C:\Program Files\SASHome\x86\SASFoundation\9.3\core\sample\update2.sas
C:\Program Files\SASHome\x86\SASFoundation\9.3\core\sample\User.gif
C:\Program Files\SASHome\x86\SASFoundation\9.3\core\sample\wordfreq.sas
NOTE: DATA statement used (Total process time):
      real time           4.93 seconds
      cpu time            0.26 seconds




二维码

扫码加我 拉你入群

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

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

关键词:Program Product Sample folder produc return names into all function

已有 1 人评分学术水平 热心指数 信用等级 收起 理由
zhangzachary + 1 + 1 + 1 精彩帖子

总评分: 学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

沙发
zhentao 发表于 2013-3-11 09:01:06
没看懂。先收藏,慢慢琢磨。

藤椅
semenljw 在职认证  发表于 2013-3-16 11:30:49
不大明白,需要仔细看一下!

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

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