由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - 百思不得其解的sas base 123题第76题
相关主题
#SAS BASE 问题,明天就考试了##问一SAS Base的题目
a problem from sas base testSAS 小问题求助!!
再问三个关于length的问题,谢谢问个SAS SCAN的问题
请教两道SAS变量长度的题目base 123题第72/73题求解:关于substr的返回长度
问一个sas的问题4another sas question
SAS BASE的一道题不明白,青椒SAS 如何处理 raw data
SAS BASE 快疯掉了!!!!苦逼的R,连个数据都读不对!!!
帮忙看一道题a question about length assignment
相关话题的讨论汇总
话题: author话题: scan话题: 分隔符话题: substr话题: run
进入Statistics版参与讨论
1 (共1页)
R*****d
发帖数: 420
1
做76题,run了程序,但就是得不出答案的200。题目如下:
data work.test;
author='Agatha Christie';
first=substr(scan(author,1,','),1,1);
run;
题目上问first的长度,我run了一下,给出的是1,但答案是200,本来这个题目确实有
些问题,author里的分隔符是space,但scan里的分隔符是逗号,如果像75题那样
author里的分隔符和scan里的分隔符一样,那么scan先取得agatha,substr再取得a,
那么length就是1.现在author里的分隔符和scan里的分隔符不一样,按理确实要run出
别的结果,但我run了,却还是1,那答案的200又是怎么得来的?哪位大拿指教一下。
a*****9
发帖数: 1315
2
这个我之前考过, 然后我上advanced SAS 课的时候, 老师特意提到这一点了 :
scan substr 这些function 针对的 $variable (如果没有特别的length function ,
而且 length还必须得在data step 之后 )
default length 是200 。
d******9
发帖数: 404
3
If you run the below codes:
data work.test;
author='Agatha Christie';
first=substr(scan(author,1,','),1,1);
L=length(first);
LC=lengthC(first);
run;
You will find: L=1, LC=200.
Therefore, first is a char variable with a length of $200, its real
internalvalue is: A+ 199 ##########.
# stands for blank spaces.
d******9
发帖数: 404
4
However, if you run the below modified codes, what will you get?
data work.test;
author='Agatha Christie';
first=substr(scan(author,1,','),1,1);
L=length(substr(scan(author,1,','),1,1));
LC=lengthC(substr(scan(author,1,','),1,1));
run;
You will get: L=1, LC=1.
Surprising? Enjoy thinking over the tricky SAS.
P****D
发帖数: 11146
5
母牛啊!还让不让人活了!

【在 d******9 的大作中提到】
: However, if you run the below modified codes, what will you get?
: data work.test;
: author='Agatha Christie';
: first=substr(scan(author,1,','),1,1);
: L=length(substr(scan(author,1,','),1,1));
: LC=lengthC(substr(scan(author,1,','),1,1));
: run;
: You will get: L=1, LC=1.
: Surprising? Enjoy thinking over the tricky SAS.

d******9
发帖数: 404
6
pat pat..... no pain, no gain.
Work hard and keep on growing.
1 (共1页)
进入Statistics版参与讨论
相关主题
a question about length assignment问一个sas的问题4
sas base 123 question 76 疑问SAS BASE的一道题不明白,青椒
如何找到两个相同character在一个string中的位置?SAS BASE 快疯掉了!!!!
如何获得最后的几个数字帮忙看一道题
#SAS BASE 问题,明天就考试了##问一SAS Base的题目
a problem from sas base testSAS 小问题求助!!
再问三个关于length的问题,谢谢问个SAS SCAN的问题
请教两道SAS变量长度的题目base 123题第72/73题求解:关于substr的返回长度
相关话题的讨论汇总
话题: author话题: scan话题: 分隔符话题: substr话题: run