一眼瞬间 发表于 2010-3-20 15:57 
bobguy 发表于 2010-3-20 09:37 
一眼瞬间 发表于 2010-3-19 13:38 
RT。
sort by的那个variable的值一共有五位数,
请教大家怎么按照前两位sort呢?
如果是按照后三位呢?
另外,这个variable是字符型变量,需不需要转换成数值型的先呢?
If the variable is num, it is better to operate it in num calculation.
data t1;
do i = 1 to 10;
x=int(10000+ranuni(12345)*90000);
x12=int(x/1e3);
x345=mod(x,1e3);
output;
end;
run;
proc print; run;
Could you explain a little bit? Why is it better to operate it in num calculation?
The numeric values have a meaningful scale. When a char function operates on a num variable, it usually needs a data type convertion which could take additional CPU time. The time is double in below.
367 %let dsn=_null_;
368
369 data &dsn;
370 do j=1 to 10;
371 do i = 1 to 10000;
372 x=int(10000+ranuni(12345)*90000);
373 x12=int(x/1e3);
374 x345=mod(x,1e3);
375 output;
376 end;
377 end;
378 run;
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.03 seconds
379
380 data &dsn;
381 do j=1 to 10;
382 do i = 1 to 10000;
383 x=int(10000+ranuni(12345)*90000);
384 x12=substr(put(x,z5.),1,2);
385 x345=substr(put(x,z5.),3,3);
386 output;
387 end;
388 end;
389 run;
NOTE: DATA statement used (Total process time):
real time 0.06 seconds
cpu time 0.06 seconds