SAS中文论坛

 找回密码
 立即注册

扫一扫,访问微社区

查看: 8370|回复: 9
打印 上一主题 下一主题

Help for SAS advance exam

[复制链接]

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
楼主
 楼主| 发表于 2010-6-3 00:34:03 | 只看该作者

Help for SAS advance exam

Hello,

Would you please let me know where I can get help if I have any question about the SAS advance exam? Can I post my SAS questions here?

I will take a SAS advance exam 30 days later and study alone, it would be great if anyone (or a forum) can help me to figure out my SAS problems / questions.

Please give me some advices above how to pass the SAS advance exam. Thank you in advance.

Best Regards,
Chunlei
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
沙发
 楼主| 发表于 2010-6-4 12:11:44 | 只看该作者

Re: Help for SAS advance exam

Question ONE:

When attempting to minimize memory usage, the most efficient way to do group processing when using the MEANS procedure is to use:
A. the BY statement.
B. GROUPBY with the NOTSORTED specification.
C. the CLASS statement.
D. multiple WHERE statements


Would you please give the answer and the reasons why it is correct? Thanks.
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
板凳
 楼主| 发表于 2010-6-6 17:59:41 | 只看该作者

Re: Help for SAS advance exam

我蒙是C(不确定)
先排除了B. GROUPBY with the NOTSORTED specification,因为我觉得proc sort和proc means中都没groupby什么事
其次排除的是D. multiple WHERE statements,多个proc means肯定比一个proc means使用的资源多
最后是在A. the BY statement和C. the CLASS statement中选一个,就选class了,因为它不需要先对数据集排序,而by选项里什么信息都没说,是数据集已经排过序了,还是能用notsorted选项什么都不知道
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
地板
 楼主| 发表于 2010-6-7 18:01:34 | 只看该作者

Re: Help for SAS advance exam

BY statement比Class statement占用内存低。运行下面程序,然后观察log窗口。 I hope this helps.

option fullstimer;

data one;
        do i=1 to 100000;
                x=ceil(i/50000);
                y=sin(i);
                output;
        end;
        drop i;
                stop;
run;

proc means data=one nonobs;
        class x;
        var y;
run;

proc means data=one nonobs;
        by x;
        var y;
run;
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
5#
 楼主| 发表于 2010-6-8 06:50:08 | 只看该作者

Re: Help for SAS advance exam

After run the above SAS codes, the log window shows that BY statement use less time. Thanks for both of you.



1    option fullstimer;
2
3    data one;
4    do i=1 to 100000;
5    x=ceil(i/50000);
6    y=sin(i);
7    output;
8    end;
9    drop i;
10   stop;
11   run;

NOTE: The data set WORK.ONE has 100000 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.49 seconds
      user cpu time       0.03 seconds
      system cpu time     0.04 seconds
      Memory                            322k
      OS Memory                         5304k
      Timestamp            07/06/2010  6:39:32 PM


12
13   proc means data=one nonobs;
14   class x;
15   var y;
16   run;

NOTE: There were 100000 observations read from the data set WORK.ONE.
NOTE: PROCEDURE MEANS used (Total process time):
      real time           1.02 seconds
      user cpu time       0.07 seconds
      system cpu time     0.04 seconds
      Memory                            9976k
      OS Memory                         16352k
      Timestamp            07/06/2010  6:39:33 PM


17
18   proc means data=one nonobs;
19   by x;
20   var y;
21   run;

NOTE: There were 100000 observations read from the data set WORK.ONE.
NOTE: PROCEDURE MEANS used (Total process time):
      real time           0.34 seconds
      user cpu time       0.03 seconds
      system cpu time     0.01 seconds
      Memory                            848k
      OS Memory                         9148k
      Timestamp            07/06/2010  6:39:33 PM
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
6#
 楼主| 发表于 2010-6-8 11:13:42 | 只看该作者

Re: Help for SAS advance exam

我还是觉得是class, 给proc sort计提预计负债更稳健些
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
7#
 楼主| 发表于 2010-6-9 04:27:17 | 只看该作者

Re: Help for SAS advance exam

BY statement is better, since it used less time and less memory (space).

After run the above example SAS codes in my computer, we can see the following,
CLASS statement: real time 1.02 seconds; user cpu time 0.07 seconds; system cpu time 0.04 seconds; Memory 9976k.
BY statement :     real time 0.34 seconds; user cpu time 0.03 seconds; system cpu time 0.01 seconds; Memory 848k.

^_^
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
8#
 楼主| 发表于 2010-6-9 14:45:15 | 只看该作者

Re: Help for SAS advance exam

应该是A
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
9#
 楼主| 发表于 2012-7-11 17:30:05 | 只看该作者

Re: Help for SAS advance exam

实践证明,还是by会快点。另外,这里牛人、好人很多,有问题他们肯定帮着会解决的。 <!-- s:D --><img src="{SMILIES_PATH}/icon_biggrin.gif" alt=":D" title="Very Happy" /><!-- s:D -->
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
10#
 楼主| 发表于 2013-3-6 14:31:57 | 只看该作者

Re: Help for SAS advance exam

答案是A。在&lt;&lt;SAS Programming 3: Advanced Techniques and Efficiencies Course Notes&gt;&gt;的2.4 Controlling Memory里面有所涉及。

[quote:27rbq7t3]Reducing Memory Usage
1. Use small data set page sizes when you create data sets that will be accessed in a sparse, random pattern.
2. Use a single read buffer when the data is accessed randomly instead of sequentially.
3. Use BY-group processing instead of CLASS statements in those procedures that support both, especially where you have pre-sorted data or can use an existing index.[/quote:27rbq7t3]

BY语句和CLASS语句关于内存区别在于:前者一次在内存只保持一个BY组,后者一次在内存中同时积累聚集所有的CLASS组。
回复 支持 反对

使用道具 举报

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

本版积分规则

QQ|小黑屋|手机版|Archiver|SAS中文论坛  

GMT+8, 2025-5-3 06:10 , Processed in 0.089702 second(s), 20 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表