楼主: hailingkatherin
5540 9

!!substr(Phonenumber,1,3)!!是什么意思呢? [推广有奖]

  • 0关注
  • 0粉丝

硕士生

82%

还不是VIP/贵宾

-

威望
0
论坛币
277 个
通用积分
0
学术水平
1 点
热心指数
5 点
信用等级
1 点
经验
164 点
帖子
126
精华
0
在线时间
87 小时
注册时间
2015-1-18
最后登录
2016-5-15

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
The following SAS program is submitted:
data work.AreaCodes;
Phonenumber=3125551212;
Code='('!!substr(Phonenumber,1,3)!!')';
run;
Which one of the following is the value of the variable Code in the output data set?
a. ( 3)
b. (312)
c. 3
d. 312
Correct answer:  a


[size=13.3333330154419px]不太明白[size=13.3333330154419px]!!substr(Phonenumber,1,3)!!,求大神解答一下!谢谢!
[size=13.3333330154419px]我觉得应该是B啊?为什么是A?请大家解答一下,谢谢了!
二维码

扫码加我 拉你入群

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

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

关键词:SUBSTR Number Phone 是什么意思 subs following

沙发
mingfeng07 学生认证  发表于 2015-2-15 23:14:11 |只看作者 |坛友微信交流群
数值变量转换为字符变量时前面都有空格。

使用道具

藤椅
wpfwxn 发表于 2015-2-16 17:31:35 |只看作者 |坛友微信交流群
!!和||地作用是一样地

使用道具

板凳
chenyuetian 发表于 2015-2-17 01:07:26 |只看作者 |坛友微信交流群
2楼正解,这个是sas base programming 中的一个考点

使用道具

报纸
goldbaodi 发表于 2015-2-17 02:53:12 |只看作者 |坛友微信交流群
A rather than B, because:

An automatic data conversion is performed whenever a numeric variable is used where SAS expects a character value. The numeric variable is written with the BEST12. format and the resulting character value is right-aligned when the conversion occurs. In this example, the value of Phonenumber is converted to character and right-aligned before the SUBSTR function is performed. Since there are only 10 digits in the value of Phonenumber, the right-aligned value begins with two blanks. Therefore the SUBSTR function picks up two blanks and a 3, and uses the BEST12. format to assign that value to Code. Then, the parentheses are concatenated before and after the two blanks and a 3.

使用道具

地板
teqel 发表于 2015-2-17 06:19:16 |只看作者 |坛友微信交流群
这就是考试中需要注意的地方,很多小陷阱

使用道具

7
hailingkatherin 发表于 2015-2-17 09:14:22 |只看作者 |坛友微信交流群
chenyuetian 发表于 2015-2-17 01:07
2楼正解,这个是sas base programming 中的一个考点
请问!!substr(Phonenumber,1,3)!!,是固定的前后两个!吗?
请问!!substr(Phonenumber,2,3)!!,这样的话答案是不是就是{  5}?

使用道具

8
琉夜 发表于 2015-2-17 16:18:32 |只看作者 |坛友微信交流群
hailingkatherin 发表于 2015-2-17 09:14
请问!!substr(Phonenumber,1,3)!!,是固定的前后两个!吗?
请问!!substr(Phonenumber,2,3)!!,这样的话 ...
!!是串联符号,就是把(和substr(Phonenumber,1,3)和)连接起来,由于substr(Phonenumber,1,3)自动把Phonenumber转化为字符型,采用的是best12格式,并且是右对齐,所以前面有两个空格,所以substr提取了两个空格和3。
所以这句的意思就是把“(”和“  3”和“)”连起来,所以选a。
!!只是串联符号。

使用道具

9
hailingkatherin 发表于 2015-2-17 20:13:51 |只看作者 |坛友微信交流群
琉夜 发表于 2015-2-17 16:18
!!是串联符号,就是把(和substr(Phonenumber,1,3)和)连接起来,由于substr(Phonenumber,1,3)自动把Ph ...
谢谢!懂了!!

使用道具

10
hu1587061 学生认证  发表于 2015-7-21 18:14:42 |只看作者 |坛友微信交流群
明白了 谢谢

使用道具

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

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

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

GMT+8, 2024-4-19 12:50