楼主: lime_kim
3043 6

[问答] 求解SAS Base 50题的No.33 [推广有奖]

  • 0关注
  • 0粉丝

本科生

11%

还不是VIP/贵宾

-

威望
0
论坛币
0 个
通用积分
0.0376
学术水平
2 点
热心指数
2 点
信用等级
1 点
经验
634 点
帖子
42
精华
0
在线时间
74 小时
注册时间
2014-8-4
最后登录
2021-12-6

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
题目如下:The following SAS program is submitted:
data test;
     input animal1 $ animal 2 $ mlgrams1 mlgrams2;
cards;
hummingbird ostrich 54000.39 90800000.87
;
run;
Which one of the following represents the values of each variable in the output data set?
a. animal1 animal2 mlgrams1 mlgrams2
    hummingb ostrich 54000.39 90800000
b. animal1 animal2 mlgrams1 mlgrams2
    hummingb ostrich 54000.39 90800000.87
c. animal1 animal2 mlgrams1 mlgrams2
    hummingbird ostrich 54000.39 90800000
d. animal1 animal2 mlgrams1 mlgrams2
    hummingbird ostrich 54000.39 90800000.87
答案是a,详解中说的是:In the INPUT statement, you must specify a dollar sign ($) after the variable name in order to define a character variable. If you do not specify otherwise, the default storage length for a variable is 8. In the example above, the character value hummingbird is truncated to hummingb.
但是题目中的animal1后面不是加上了$么?而且如果数值型变量的默认长度是8位,为什么90800000.87没有变成90800000呢?小白求解啊~~~谢各路大神
二维码

扫码加我 拉你入群

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

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

关键词:SAS base Base represents following Character represents following animal values

沙发
happinessiam 发表于 2015-2-17 22:31:46 |只看作者 |坛友微信交流群
length指的是储存的长度,和字符个数没有关系。但一个字母恰好对应一个存储长度。8 length能表示挺大的数。具体多少忘记了。

使用道具

藤椅
CathyHong 发表于 2015-2-17 23:17:04 |只看作者 |坛友微信交流群
我记得这个应该是b
animal1和animal2后面加上 $\$$表示存储char型变量, $后面的数字表示字符长度,缺省值为8,所以是
hummingb ostrich
mlgrams1 mlgrams2表示numeric型变量,以best12显示,因为两个长度都小于12个字符长度,所以是                                                                                                                                                54000.39 90800000.87, 如果增加整数或小数部分长度使其超过12的话则显示出来的是10为底指数或小数部分四舍五入      
            

使用道具

板凳
lime_kim 发表于 2015-2-17 23:46:20 |只看作者 |坛友微信交流群
CathyHong 发表于 2015-2-17 23:17
我记得这个应该是b
animal1和animal2后面加上 $\$$表示存储char型变量, $后面的数字表示字符长度,缺省值为 ...
谢谢啊~~~

使用道具

报纸
lime_kim 发表于 2015-2-17 23:49:31 |只看作者 |坛友微信交流群
CathyHong 发表于 2015-2-17 23:17
我记得这个应该是b
animal1和animal2后面加上 $\$$表示存储char型变量, $后面的数字表示字符长度,缺省值为 ...
答案确实是b,不好意思打错了~

使用道具

地板
hwyale 发表于 2015-3-16 06:02:55 |只看作者 |坛友微信交流群
CathyHong 发表于 2015-2-17 23:17
我记得这个应该是b
animal1和animal2后面加上 $\$$表示存储char型变量, $后面的数字表示字符长度,缺省值为 ...
还是不明白

http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a001103996.htm

你看这里输得很清楚啊是8位,为什么不truncate?

使用道具

7
CathyHong 发表于 2015-3-24 08:49:25 |只看作者 |坛友微信交流群
hwyale 发表于 2015-3-16 06:02
还是不明白

http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a001 ...
8 bytes 是指当你存储numeric变量时,在内存空间中占8个bytes长度,即64bit。输出在屏幕上的长度则要看format,默认best12.
比如说,当你存储1, 11.11, 1111.1111111111这三个数占用的内存空间同为8byte,但你输出时则显示为1, 11.11, 1111.1111111

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000184495.htm

使用道具

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

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

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

GMT+8, 2024-5-2 00:41