楼主: dolphinfish
2064 5

[原创博文] 请教:array 和 hash [推广有奖]

  • 0关注
  • 0粉丝

讲师

24%

还不是VIP/贵宾

-

威望
0
论坛币
2753 个
通用积分
0.4550
学术水平
1 点
热心指数
4 点
信用等级
1 点
经验
13027 点
帖子
150
精华
0
在线时间
679 小时
注册时间
2009-8-26
最后登录
2021-5-29

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
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好像差不多是吧?

谢谢!
二维码

扫码加我 拉你入群

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

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

关键词:array HASH ARR Has Ray benefit correct values

回帖推荐

soporaeternus 发表于2楼  查看完整内容

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

bobguy 发表于5楼  查看完整内容

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

本帖被以下文库推荐

沙发
soporaeternus 发表于 2010-3-6 22:27:48 |只看作者 |坛友微信交流群
对于问题2
我的理解array是变量名的一个list,使得代码本身对变量的操作更简单。某种意义上来说,macro也可以完成这部分的工作,而且我觉得代码维护性更强。
而hash很多时候可以弥补data步对之前数据“回顾性”差的弱点,可以较为简单地完成很多复杂的数据变换。速度很快......
已有 1 人评分经验 论坛币 收起 理由
bakoll + 3 + 3 精彩帖子

总评分: 经验 + 3  论坛币 + 3   查看全部评分

Let them be hard, but never unjust

使用道具

藤椅
bobguy 发表于 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.

使用道具

板凳
dolphinfish 发表于 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!

使用道具

报纸
bobguy 发表于 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
已有 1 人评分经验 论坛币 收起 理由
bakoll + 3 + 3 精彩帖子

总评分: 经验 + 3  论坛币 + 3   查看全部评分

使用道具

地板
dolphinfish 发表于 2010-3-7 08:43:32 |只看作者 |坛友微信交流群
got you. thanks!

使用道具

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

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-30 23:19