全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
3566 7
2012-05-26

32.Consider the following data step:

data WORK.NEW;

    set WORK.OLD;

    Count+1;

run;

The variable Count is created using a sum statement. Which statement regarding this variable is true?

     A. It is assigned a value 0 when the data step begins execution.

     B. It is assigned a value of missing when the data step begins execution.

     C. It is assigned a value 0 at compile time.

     D. It is assigned a value of missing at compile time.

Answer: C

答案说在编译阶段就给赋值为0了。可是编译阶段不是都没有值吗?

二维码

扫码加我 拉你入群

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

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

全部回复
2012-5-26 21:51:07
没人给说说吗?
二维码

扫码加我 拉你入群

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

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

2012-5-26 22:40:48
First one needs to understand the retain statement. It is classified as non-executable statement. This is very important!

count +1;

is equivalent to

count=count+1;
retain count 0;

data t1;
   set sashelp.class;
   count=count+1;
   retain count 0;
run;

proc print;run;

If you assign a missing to count in retain statement, you will get all counts as missing.


The other way to understand it is to wrap them into a do block as below,

if 0 then do;
set sashelp.class;
   count+1;
end;

As we know that every statements will not get executed at running time because ' if 0  ' is never true. In other words these statements provide information at compiling time only.  The put statement let you see what is the value of count at compiling time .  


data _null_;
  if 0 then do;
   set sashelp.class;
   count+1;
  end;
  put count;
run;
二维码

扫码加我 拉你入群

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

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

2012-5-26 23:43:13
bobguy 发表于 2012-5-26 22:40
First one needs to understand the retain statement. It is classified as non-executable statement. Th ...
Thank you very much.
就是英文能不能不这么给力啊!
二维码

扫码加我 拉你入群

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

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

2012-5-26 23:51:40

sas的编译阶段

bobguy 发表于 2012-5-26 22:40
First one needs to understand the retain statement. It is classified as non-executable statement. Th ...
捕获6.PNG
非常感谢这个大侠给的解释。解开了我的一个盲点。
自己也运行了一下程序。
确实是这样的。

二维码

扫码加我 拉你入群

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

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

2012-5-27 01:01:54
bobguy 发表于 2012-5-26 22:40
First one needs to understand the retain statement. It is classified as non-executable statement. Th ...
想问你个事情,我也看了base programing
但是上面没有讲关于retain语句的是非执行语句等有关问题。
我想知道你是看的哪些方面的书,能推荐一下吗?
二维码

扫码加我 拉你入群

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

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

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

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