654 data _1;
655 do i =1 to 100000000;
656 output;
657 end;
658 run;
NOTE: The data set WORK._1 has 100000000 observations and 1 variables.
NOTE: DATA statement used:
real time 1:59.40
cpu time 53.90 seconds
[color=blue:1e94d]678 data _null_;
679 *count =nobs;
680 put _all_;
681 stop;
682 set work._1 nobs=nobs;
683 run;[/color:1e94d]
nobs=100000000 i=. _ERROR_=0 _N_=1
NOTE: DATA statement used:
real time 0.00 seconds
cpu time 0.00 seconds
[color=red:1e94d]/*这个方法的时间消耗和数据的多少没有什么关系*/[/color:1e94d]
[color=blue:1e94d]
/*另外我看了一下内存的消耗。和上面两位的方法相比,好象也未增加,不知为什么,按理下面第一种方法内存消耗大些,请各位知道原因的指教
还有,请问willon,用count(1) 好象没有太大变化,有什么技巧?*/[/color:1e94d]
700 options fullstimer;
701 data _null_;
702 *count =nobs;
703 put _all_;
704 stop;
705 set work._1 nobs=nobs;
706 run;
nobs=100000000 i=. _ERROR_=0 _N_=1
NOTE: DATA statement used:
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
Memory 95k
707 proc sql;
708 select count(*)
709 from _1;
710 quit;
NOTE: PROCEDURE SQL used:
real time 36.60 seconds
user cpu time 31.67 seconds
system cpu time 0.93 seconds
Memory 125k
712 proc sql;
713 select count(1)
714 from _1;
715 quit;
NOTE: PROCEDURE SQL used:
real time 36.40 seconds
user cpu time 36.01 seconds
system cpu time 0.00 seconds
Memory 93k
[color=blue:4548d]
/*上述测试不一定代表确切情况,请yiming先生测试您自己的数据,再权衡这四种消耗*/[/color:4548d]