全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
2302 5
2010-03-06
1. What is the benefit of adding _temporary_ to arrays?  Is this going to save CPU or disk space?  My understanding is that, in both cases, all the values stored in the arrays will be gone after the session.  Is this correct?
2. 到底用hash有什么好处呢?总体来说和array好像差不多是吧?

谢谢!
二维码

扫码加我 拉你入群

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

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

全部回复
2010-3-6 22:27:48
对于问题2
我的理解array是变量名的一个list,使得代码本身对变量的操作更简单。某种意义上来说,macro也可以完成这部分的工作,而且我觉得代码维护性更强。
而hash很多时候可以弥补data步对之前数据“回顾性”差的弱点,可以较为简单地完成很多复杂的数据变换。速度很快......
二维码

扫码加我 拉你入群

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

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

2010-3-6 22:46:52
dolphinfish 发表于 2010-3-6 12:48
1. What is the benefit of adding _temporary_ to arrays?  Is this going to save CPU or disk space?  My understanding is that, in both cases, all the values stored in the arrays will be gone after the session.  Is this correct?
2. 到底用hash有什么好处呢?总体来说和array好像差不多是吧?

谢谢!
Here is an article about HASH,

http://en.wikipedia.org/wiki/Hash_function

SAS temporary array is just a memory location to store any intermediate resutls for later use in a data step. It can improve a great deal of performance if one use it properly. For example, if keys are integers and continuous in a range that one knows in advance, a direct key serach table can be bulit in temporary array. But unlike hask object it has many limitations.
二维码

扫码加我 拉你入群

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

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

2010-3-6 23:56:16
Thanks to both.

But one more question to follow up Bobguy:

Temp array is a memory location.  How about "non-temp" array?  Isn't it also a memory location during just that DATA step?  How is a temp array (vs. non-temp) better in terms of resources (CPU, disk space, PDV,etc.) that you would bother to specify _temporary_?

Thanks!
二维码

扫码加我 拉你入群

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

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

2010-3-7 00:20:02
dolphinfish 发表于 2010-3-6 23:56
Thanks to both.

But one more question to follow up Bobguy:

Temp array is a memory location.  How about "non-temp" array?  Isn't it also a memory location during just that DATA step?  How is a temp array (vs. non-temp) better in terms of resources (CPU, disk space, PDV,etc.) that you would bother to specify _temporary_?

Thanks!
The reference array is just variable reference which can simplify your programming in a great deal. It is just a reference.

115  data _null_;
116   array x(*) x1-x2;
117      x1=1; x2=2;
118      put x1= x(1)=/x2= x(2)=;
119      x1=21; x2=22;
120      put x1= x(1)=/x2= x(2)=;
121
122   run;

x1=1 x1=1
x2=2 x2=2
x1=21 x1=21
x2=22 x2=22
二维码

扫码加我 拉你入群

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

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

2010-3-7 08:43:32
got you. thanks!
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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