SAS Functions 转换变量类型的方式。
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
解答:在SAS中**!!代表拼接字符串**。Phonenumber在编译时是数值变量,10位的。后面用到的substr()函数,是截取字符串函数,**会把数值函数转换成字符串函数。转换的格式是best12.,对其方式是右对齐。所以在前面两个会填充两个空格。**所以substr()截取到的是( 3).