SAS中文论坛

标题: Help for SAS advance exam [打印本页]

作者: shiyiming    时间: 2010-6-3 00:34
标题: 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
作者: shiyiming    时间: 2010-6-4 12:11
标题: 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.
作者: shiyiming    时间: 2010-6-6 17:59
标题: 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选项什么都不知道
作者: shiyiming    时间: 2010-6-7 18:01
标题: 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;
作者: shiyiming    时间: 2010-6-8 06:50
标题: 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
作者: shiyiming    时间: 2010-6-8 11:13
标题: Re: Help for SAS advance exam
我还是觉得是class, 给proc sort计提预计负债更稳健些
作者: shiyiming    时间: 2010-6-9 04:27
标题: 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.

^_^
作者: shiyiming    时间: 2010-6-9 14:45
标题: Re: Help for SAS advance exam
应该是A
作者: shiyiming    时间: 2012-7-11 17:30
标题: Re: Help for SAS advance exam
实践证明,还是by会快点。另外,这里牛人、好人很多,有问题他们肯定帮着会解决的。 <!-- s:D --><img src="{SMILIES_PATH}/icon_biggrin.gif" alt=":D" title="Very Happy" /><!-- s:D -->
作者: shiyiming    时间: 2013-3-6 14:31
标题: 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组。




欢迎光临 SAS中文论坛 (http://www.mysas.net/forum/) Powered by Discuz! X3.2