由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - SAS adv question.请大家帮忙看看
相关主题
请问两道sas adv的题..[提问]怎样sort这个dataset?
sas adv 63题 52which route in SAS is faster?
SAS dataset 中,怎么把数据往上移一行?求教一个简单的data step 牛肉包
SAS处理Large Dataset太慢了,怎么办?[合集] SAS里如何实现LOCF(LAST OBS CARRIED FORWARD)?
SAS 问题:关于比较variable 包子答谢[SAS] data set options (obs=) in output tables
请教几个ADV问题SAS中FORMAT问题求教
讨论3道SAS ADV题目one quick question about concatenating data in SAS
如何比较两个proc contents的结果?a SAS question in base 70
相关话题的讨论汇总
话题: data话题: sas话题: set话题: sorted话题: dataset
进入Statistics版参与讨论
1 (共1页)
s******o
发帖数: 283
1
Item 52
To create a dataset with unique values of a given varible using a data
step
and the FIRST. and LAST. varaibales, it is
assumed that the input dataset is:
A. sorted on that variable.
B. indexed by that variable.
C. naturally in order.
D. any of the above A, B, or C
答案为何不是D?因为这里只是要求unique value,所以在同一个组里的任意一个值都可以,所以在
这里对顺序并没有要求,所以并不要求sort or index or any order????
s******o
发帖数: 283
2
自己顶一下,有没有高人可以解释一下答案为啥是A呢?thanks a lot!

都可以,所以在

【在 s******o 的大作中提到】
: Item 52
: To create a dataset with unique values of a given varible using a data
: step
: and the FIRST. and LAST. varaibales, it is
: assumed that the input dataset is:
: A. sorted on that variable.
: B. indexed by that variable.
: C. naturally in order.
: D. any of the above A, B, or C
: 答案为何不是D?因为这里只是要求unique value,所以在同一个组里的任意一个值都可以,所以在

f**********6
发帖数: 365
3
first, last only work with sorted dataset.

都可以,所以在

【在 s******o 的大作中提到】
: Item 52
: To create a dataset with unique values of a given varible using a data
: step
: and the FIRST. and LAST. varaibales, it is
: assumed that the input dataset is:
: A. sorted on that variable.
: B. indexed by that variable.
: C. naturally in order.
: D. any of the above A, B, or C
: 答案为何不是D?因为这里只是要求unique value,所以在同一个组里的任意一个值都可以,所以在

s******o
发帖数: 283
4
thanks for your help,
but from SAS base "reading SAS dataset----using By-group processing" it
says,
"When you use the BY statement with the SET statement,
the data sets that are listed in the SET statement must be sorted by the
values of the BY variable(s), or they must have an appropriate index."
so answer B is possible?
and from adv-prep-guide,
"The NOTSORTED option can be used with FIRST.variable and LAST.variable,
example:
data work.new;
set company.sales
by ordername notsorted;
run;
"
so answer C is possible?
so overall, the answer is D?

【在 f**********6 的大作中提到】
: first, last only work with sorted dataset.
:
: 都可以,所以在

p*******i
发帖数: 1181
5
这个C肯定不行 我工作时候碰到过 都是Excel里排好然后导入的 还是会报错 sort以后
就没问题了
s******o
发帖数: 283
6
do you mean if you use " notsorted " option in the by statement, it still
canot work?

【在 p*******i 的大作中提到】
: 这个C肯定不行 我工作时候碰到过 都是Excel里排好然后导入的 还是会报错 sort以后
: 就没问题了

d******9
发帖数: 404
7
The answer should be D.
I tried with below data: natural in order.
data A;
input A B $;
cards;
1 a
5 t
5 W
7 h
9 D
;
run;
data B;
set A;
by A;
if first.A then output;
run;
SAS Output:
Obs A B
1 1 a
2 5 t
3 7 h
4 9 D
d******9
发帖数: 404
8
No.
Please see me below example.

【在 f**********6 的大作中提到】
: first, last only work with sorted dataset.
:
: 都可以,所以在

s******o
发帖数: 283
9
Thanks so much for your help again, dido2009.
I know you did not sort the data set A before you use it for data B.But
does
data set A itself look like it is sorted already? because A variable in
this dataset is arranged in ascending order(1,5,7,9) already? and when
you
use it for data B, there is
set A;
By A;
with the combination of "set" and "by" statement, it require that data A
is
sorted or indexed as I referred above in SAS base"By group processing"
??
Do you know the result if the data set A has variable A in the random
order(
e.g. 1, 7,5,9) and is it possible to produce data B using "set"
statement
without "by" statement(because varialbe A is not sorted here)?

【在 d******9 的大作中提到】
: The answer should be D.
: I tried with below data: natural in order.
: data A;
: input A B $;
: cards;
: 1 a
: 5 t
: 5 W
: 7 h
: 9 D

s******o
发帖数: 283
10
dido2009, thanks for your help, I actually run the code below:
data C;
input A B $;
cards;
5 t
5 W
7 h
1 a
9 D
;
run;
data B;
set C;
By A notsorted;
if first.A then output;
run;
and the SAS result is
5 t
7 h
1 a
9 D
so as you said answer C is possible( when data is in natural order). then
answer is D.

【在 s******o 的大作中提到】
: Thanks so much for your help again, dido2009.
: I know you did not sort the data set A before you use it for data B.But
: does
: data set A itself look like it is sorted already? because A variable in
: this dataset is arranged in ascending order(1,5,7,9) already? and when
: you
: use it for data B, there is
: set A;
: By A;
: with the combination of "set" and "by" statement, it require that data A

1 (共1页)
进入Statistics版参与讨论
相关主题
a SAS question in base 70SAS 问题:关于比较variable 包子答谢
do loop 的一道题请教几个ADV问题
询问一个SAS数据处理问题讨论3道SAS ADV题目
请教SAS中如何如果flag的问题如何比较两个proc contents的结果?
请问两道sas adv的题..[提问]怎样sort这个dataset?
sas adv 63题 52which route in SAS is faster?
SAS dataset 中,怎么把数据往上移一行?求教一个简单的data step 牛肉包
SAS处理Large Dataset太慢了,怎么办?[合集] SAS里如何实现LOCF(LAST OBS CARRIED FORWARD)?
相关话题的讨论汇总
话题: data话题: sas话题: set话题: sorted话题: dataset