SAS中文论坛

标题: 关于在线认证教程上的一个疏漏 [打印本页]

作者: shiyiming    时间: 2006-9-10 00:25
标题: 关于在线认证教程上的一个疏漏
<!-- m --><a class="postlink" href="http://www.mysas.net/dE4Kwu7P2v/59322/m40/m40_39.htm">http://www.mysas.net/dE4Kwu7P2v/59322/m40/m40_39.htm</a><!-- m -->
第九题:给出的答案是d。但是我通过程序试验以后明显有问题。下面是我的程序
data house;
input style$ bedroom bath;
cards;
twostory 2.666666 2.5
;
run;

例1:proc report;
                 column style bedroom bath;
                 define style / 'Style of House';
                 define bedroom / 'Average Bedrooms';
                 define bath / 'Maximum baths';
          run;

大家注意结果Style of house这个column heading并不是按照题目所给那样。

所以,答案给出的参考(下面两句话)并没有正确的解释题目的考点:
If a variable in the input data set doesn't have a format associated with it, the default PROC REPORT column width is :
the variable's length for character variables
9 for numeric variables.

显然,这道题目还需要考虑column's width确定的时候,在define statement 中的'column-heading' 中的空格如何影响column heading的显示:
大家再看看下面的例子:
2)proc report;
              column style bedroom bath;
              define style / 'Style of House';      
              define bedroom / 'AverageBed rooms';                         /*词的长度大于column width*/
              define bath / 'Maximumbaths';                                       /*没有空格*/
     run;

3)proc report;
               column style bedroom bath;
               define style /width=7 'Style of House';                         /*改变了width*/
               define bedroom /width=9  'Average Bedrooms';
               define bath / 'Maximum baths';
      run;
总结如下:
从例2可是看出,SAS会自动认为空格是分词符号,因此在空格之间的词不会被分开(除非一个词的长度大于width时,这个词会被分开在两行显示);若没有空格出现时情况就变得很简单,就是一直显示直到第一行满,再第二行……
例3,改变width=7以后(例1中是width=8),column heading显示为3行,更加能看出空格的作用了。




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