全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
3205 4
2009-04-16

我在自己的PC上运行SAS宏程序,估计时间较长,起码要好几小时,请问能否在运行时,查看运行需要多少时间或倒计时?

二维码

扫码加我 拉你入群

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

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

全部回复
2009-4-17 09:38:00
应该是可以的,但我历来都是通过log看时间的
二维码

扫码加我 拉你入群

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

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

2009-4-17 18:27:00

/***************************************************************************************/
/* 指定LOG存放目录,程序统计该目录下所有LOG程序的运行时间 */
%let pathname=%str(D:\Downloads);

/********** 程序开始 **********/
options noxwait;
x "cd &pathname.";
x "dir *.log >dirfile";

filename dirfile "&pathname.\dirfile";
data lognamefile;
 infile dirfile end=fend length=length;
 length logname str $255;
 input str $varying. length;
 if length>40 and lowcase(substr(str,length-3,4))='.log' then do;
  logname=substr(str,37,length-36);
  keep logname;
  output;
 end;
run;

x "del dirfile";

%macro real_time();
 %if %sysfunc(exist(pgm_real_time)) %then %do;
  proc delete data=pgm_real_time;run;
 %end;
 %let dsid=%sysfunc(open(lognamefile));
 %if &dsid>0 %then %do;
   %let nobs=%sysfunc(attrn(&dsid,nobs));
  %do i=1 %to &nobs;
   %let rc=%sysfunc(fetchobs(&dsid,&i));
   %let logname=%sysfunc(getvarc(&dsid,%sysfunc(varnum(&dsid,logname))));
   %put 开始计算LOG程序运行时间:&logname;
   filename logfile "&pathname.\&logname.";
   data pgm_real_time_0;
    infile logfile end=fend length=length;
    length real_time cpu_time $20 log_name $100 data_step $10 str $255;
    log_name="&logname.";
    retain data_step real_time end_flag;
    input str $varying. length;
    if find(str,'NOTE: SAS 系统所用时间:','I') then do;
     end_flag=1;
    end;
    if find(str,'实际时间','I') then do;
     if end_flag ne 1 then do;
      n+1;
      data_step=compress("第"||put(n,z6.)||"步");
      real_time=left(compress(str,'实际时间'));
     end;
     else do;
      data_step="合计";
      real_time=left(compress(str,'实际时间'));
     end;
    end;
    if find(str,'CPU 时间','I') then do;
     cpu_time=left(compress(str,'CPU 时间'));
     output;
    end;
    drop n str end_flag;
   run;
   proc append base=pgm_real_time data=pgm_real_time_0;run;
   proc delete data=pgm_real_time_0;run;
  %end;
 %end;
 %let dsid=%sysfunc(close(&dsid));
%mend;

%real_time;

/********** 程序结束 **********/

在SAS应用班视频教学里面有很详细的程序解读。


二维码

扫码加我 拉你入群

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

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

2010-6-13 15:02:55
请问nkwilling,你是姚志勇么? 久仰久仰啊! 能否给个联系方式,向您请教一些建模的问题!
二维码

扫码加我 拉你入群

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

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

2010-6-13 15:15:52
onlystrong 发表于 2010-6-13 15:02
请问nkwilling,你是姚志勇么? 久仰久仰啊! 能否给个联系方式,向您请教一些建模的问题!
你给我QQ,发到我站内邮箱。另外,希望不要在公共场合直呼其名,低调点^_^。
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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