请选择 进入手机版 | 继续访问电脑版
楼主: avivian
2760 4

对比两个SAS题库的程序,为什么结果不一样? [推广有奖]

  • 0关注
  • 0粉丝

初中生

47%

还不是VIP/贵宾

-

威望
0
论坛币
275 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
56 点
帖子
5
精华
0
在线时间
17 小时
注册时间
2005-5-15
最后登录
2021-8-19

avivian 发表于 2014-11-27 01:14:47 |显示全部楼层 |坛友微信交流群

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
1.
The following SAS program is submitted:
data work.retail;
cost = '20000';
total = .10 * cost;
run;
Which one of the following is the value of the variable TOTAL in the output data
set?
A. 2000
B. '2000'
C. . (missing numeric value)
D. ' ' (missing character value)

答案为A,理由是SAS automaticly converted the character value cost to numeric 20000.

但是另一道题:
30.The descriptor and data portions of the Work.Salaries data set are shown below.
Variable Type Len Pos
name   Char  8     0
salary   Char  8    16
status  Char  8     8

name    status salary
Liz         S       15,600
Herman S       26,700
Marty    S       35,000

The following SAS program is submitted:
proc print data=work.salaries;
where salary<20000;
run;

What is displayed in the SAS log after the program is executed?
a. A NOTE indicating that 1 observation is read.
b. A NOTE indicating that 0 observations were read.
c. A WARNING indicating that character values have been converted to numeric values.
d. An ERROR indicating that the WHERE clause operator requires compatible variables.
答案是D。

我想问为什么第2题SAS没有自动将character转为numeric,而第1题这么做了?

谢谢。
二维码

扫码加我 拉你入群

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

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

关键词:following Character Automatic converted salaries 程序

teqel 发表于 2014-11-27 11:48:37 |显示全部楼层 |坛友微信交流群
因为第一题里面的Total是数值变量,第二题salary   是字符变量

使用道具

sas_user 发表于 2014-12-11 06:06:03 |显示全部楼层 |坛友微信交流群
自动转换字符类型只发生在data step, proc sql和macro中

使用道具

meowlac 发表于 2014-12-11 11:02:53 |显示全部楼层 |坛友微信交流群
第一个用了乘法,做了运算,第二题只是where condition

使用道具

avivian 发表于 2014-12-14 00:24:15 |显示全部楼层 |坛友微信交流群
sas_user 发表于 2014-12-11 06:06
自动转换字符类型只发生在data step, proc sql和macro中
好的,谢谢你。

使用道具

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

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

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

GMT+8, 2024-4-18 12:54