全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
2984 4
2014-11-27
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题这么做了?

谢谢。
二维码

扫码加我 拉你入群

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

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

全部回复
2014-11-27 11:48:37
因为第一题里面的Total是数值变量,第二题salary   是字符变量
二维码

扫码加我 拉你入群

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

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

2014-12-11 06:06:03
自动转换字符类型只发生在data step, proc sql和macro中
二维码

扫码加我 拉你入群

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

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

2014-12-11 11:02:53
第一个用了乘法,做了运算,第二题只是where condition
二维码

扫码加我 拉你入群

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

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

2014-12-14 00:24:15
sas_user 发表于 2014-12-11 06:06
自动转换字符类型只发生在data step, proc sql和macro中
好的,谢谢你。
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群