o****n 发帖数: 281 | 1 遇到了几个SAS ADV问题,希望大家帮忙看下,谢谢了!
question 1:
The SAS data set WORK.TEST has an index
on the variable Id and the following SAS
program is submitted.
data WORK.TEST;
set WORK.TEST(
keep=Id Var_1 Var_2
rename=(Id=Id_Code));
Total=sum(Var_1, Var_2);
run;
请问这里的indexed variable Id是否在重命名之后,其index就被删除了?有以下几个
选项:
A.
The index on Id is deleted.
B.
The index on Id is updated as an index on Id_Code.
C.
The index on Id is deleted and an index on Id_Code is created.
D.
The index on Id is recreated as an index on Id_Code.
QUESTION 2:
For match-merge BY variables, they should have the same ...
A. name and type
B. name
C. name and length
D. name and type and length | d******9 发帖数: 404 | 2 First question is a very good question. I think the answer is A:
A. The index on Id is deleted.
I run the codes in SAS, and found that the index on ID is really gone. | o****n 发帖数: 281 | 3
Thank you so much dido2009! I think it should be A.
How about question 2? I think they should have the same name and type, but
not sure...
Thanks!
【在 d******9 的大作中提到】 : First question is a very good question. I think the answer is A: : A. The index on Id is deleted. : I run the codes in SAS, and found that the index on ID is really gone.
| d******9 发帖数: 404 | 4 Question 2, they should have same name and type. You are right.
However, if they have different lengths, SAS may give you a warning in LOG,
although it will execute without errors.
For example, if you run below codes:
data T1;
length D $5;
input D staff;
cards;
AAA 36
BBB 89
;
run;
data T2;
length D $10;
input D staff;
cards;
AAA 780
BBB 512
;
run;
data T3;
merge T1 T2;
by D;
run;
You will have this WARNING
WARNING: Multiple lengths were specified for the BY variable D by input data
sets. This may cause unexpected results.
However if you change the merge order:
17 data T3;
18 merge T2 T1;
19 by D;
20 run;
Then no warning in LOG. Because the variable length is determined by first
occurrence in SAS ! | o****n 发帖数: 281 | 5
LOG,
I appreciate your help, dido2009! That is really helpful :)
【在 d******9 的大作中提到】 : Question 2, they should have same name and type. You are right. : However, if they have different lengths, SAS may give you a warning in LOG, : although it will execute without errors. : For example, if you run below codes: : data T1; : length D $5; : input D staff; : cards; : AAA 36 : BBB 89
|
|