由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - another sas question
相关主题
a question about length assignment#SAS BASE 问题,明天就考试了##
SAS BASE的一道题不明白,青椒Another SAS perl question
再问三个关于length的问题,谢谢弱问:一道BASE题,怎么也不明白
SAS BASE 快疯掉了!!!!a problem from sas base test
还问道SAS的题目sas base 123 question 76 疑问
SAS base string question百思不得其解的sas base 123题第76题
如何找到两个相同character在一个string中的位置?如何获得最后的几个数字
base 123题第72/73题求解:关于substr的返回长度sas question。
相关话题的讨论汇总
话题: length话题: sas话题: first话题: matrix话题: city
进入Statistics版参与讨论
1 (共1页)
d*******1
发帖数: 293
1
data work. test;
First = 'Ipswich, England';
City_Country = substr(First, 1, 7)!!', '! !'England';
run;
Which one of the following is the length of the variable CITY_COUNTRY in the
output data set?
A. 6
B. 7
C. 17
D. 25
Answer: D
But when I run the program in SAS, it is 16. How here get 25, just because
substr do not change length of First? but why I got 16 from SAS?
P****D
发帖数: 11146
2
The answer is indeed 25. Take a look at the attribute of variable "City_Country" and you will find the length is 25. The length of substr(First, 1, 7) is still 16, as First has a length of 16.
d*******1
发帖数: 293
3
Yes, I got 25 from attribute.
But why when I used Length(City_Country) in SAS program and got 16?
P****D
发帖数: 11146
4
According to SAS Help and Documentation -
LENGTH Function
finds the lengths of character matrix elements
LENGTH( matrix)
where matrix is a character matrix or quoted literal.
The LENGTH function takes a character matrix as an argument and produces a
numeric matrix as a result. The result matrix has the same dimensions as the
argument and contains the lengths of the corresponding string elements in
matrix. The length of a string is equal to the position of the rightmost
nonblank character in the
d*******1
发帖数: 293
5
I got it. Thanks.
1 (共1页)
进入Statistics版参与讨论
相关主题
sas question。还问道SAS的题目
请教两道SAS变量长度的题目SAS base string question
用R出现怪问题。如何找到两个相同character在一个string中的位置?
这个R程序能帮改进一下吗?base 123题第72/73题求解:关于substr的返回长度
a question about length assignment#SAS BASE 问题,明天就考试了##
SAS BASE的一道题不明白,青椒Another SAS perl question
再问三个关于length的问题,谢谢弱问:一道BASE题,怎么也不明白
SAS BASE 快疯掉了!!!!a problem from sas base test
相关话题的讨论汇总
话题: length话题: sas话题: first话题: matrix话题: city