全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1848 1
2017-09-05

21.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  

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。

提问 为什么会是right-alinged???是BEST12 format自带的结果吗???求大神回复谢谢!
二维码

扫码加我 拉你入群

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

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

全部回复
2017-9-6 01:55:47
ask for help
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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