|
SAS ADVANCED 質素機經 by mikeleung110
新題庫updated by 02.Jan.2018 by MZX
ASK: A Data has 2000million observations and 300 Character variables
ASK:Compress=YES
FIB:YES
OR 選擇題
A COMPRESS=YES
B COMPRESS=HEX
C COMPRESS=BIN
D COMPRESS=NUM
ANS:A
Q:FCMP 选择题
proc fcmp outlib=sasuser.funcs.trial;
…
endsub;
options ____cmplib_____=sasuser.funcs;
data null;
…
run;
ANS: cmplib
选择题原题
Q:What option force the use of a specific index from dataset?
Ans: IDXNAME
Q:MACRO选择题
%let this_year=%substr(&sysdate9, 6);
%let next_year=&this_year+1;
%let check_year=%eval(&next_year<2016);
%put two years after this year is &next_year+1;
%put check_year is &check_year;
Assume system time is 01Jan2013, what is the output?
ANS: Two years after this year is 2013+1+1
check_year is 1
Q:Multi-array选择题(记住output)
Array multi{1:2, 2}(1,2);
Do i=1 to 2;
Do j=1 to 2;
Output=multi{I,j};
What are the corresponding values of i, j, and output.
A 2*2 multi-array, only two initial values, so the array is following
i j output
1 1 1
1 2 2
2 1 .
2 2 .
Q:Pagesize info
Which of proc can check the pagesize info?
A. Proc Contents
B. Proc print
C. Proc report
D. Proc catalog
ANS:A
变体:选项改变了表达方式
Q: Pagesize Info
A. Content procedure
B. Catalog procedure
C. Print procedure
D. Report procedure
Q: KEEP&DROP statement and option Efficiency
A data set has 300,000 observations, 20 character variables, 50 numeric variables. We need 5 character
variables and 7 numeric variables, which one is the most efficient:
A. Drop=option in data step
B. KEEP=option in data step
C. Keep =option in set statement
D. Keep statement
Answer: Keep=option in set statement. With it the system only read the desired variables.
Q45 变形 选择题
(i)
Given data sets and SQL code with Select Distinct statement, which one has the same output.
The correct answer is proc SORT with Nodupkey, and with an option(drop=XXX).
Besides, BY variable cannot have the descending option, because in the SQL procedure, ORDER BY
statement is in ascending order. So choose the answer like following:
proc sort data=XXX
out=work.sorted (drop=xxx) nodupkey;
by order_var;
run;
IF First.Customer_ID choice doesn’t sort the data first, so cannot be used.
这道题的原题模式我尽量记下来了
WORK.SALES
ClientID Name Sales
400 xxx 00000
100 Xxx …
200 Xxx …
100 Xxx …
300 Xxx …
400 Xxx …
100
…… Xxx …
SAS program is submitted: (应该没记错...)
proc sql;
select distinct
ClientID
Name
from Sales;
order by ClientID;
run;
Output:
ClientID Name
100 Xxx
200 Xxx
300 Xxx
400 xxx
A. proc sort data = Sales out = work.sorted (drop Sales);
by ClientID;
run;
B. proc sort data = Sales out = work.sorted nodupkey;
by ClientID;
run;
C. proc sort data = Sales out = work.sorted (drop Sales) nodupkey;
by ClientID;
run;
D. proc sort data = Sales out = work.sorted (drop Sales) nodupkey;
by descending ClientID;
run;
我选C. 感觉机经里面也是这个意思。
正确答案具备以下特点:
1. 有(drop Sales),可以看到output里已经没有Sales
2. 有nodupkey, 符合题目给的SAS code - “proc sql; select distinct…”,创造unique key
3. 给的code和output都能看出是按照ascending ClientID排列。D肯定错。
Q:Using View
Data finance .newdata/view=finance.newdata;
Infile<fileref>;
<Data step statements>;
run;
Submit the above code and create a data step view, then we need to use this view in the PROC MEANS
procedure, which one to use:
A. Proc Means view=finance.newdata;
B. Proc Means data= finance.newdata/view= finance.newdata;
C. Proc means data finance.newdata/view
D. Proc means data= finance.newdata
Answer: D. proc means data=dataset_name. The same way as to use a normal data set.
选没有view最短的那项
Q:MACRO
Given data set and macro program, choose missing correct code
A. &Num=California
B. call symputx(‘Num’, California)
有个干扰项是symputx(‘Num’, California),别漏了call
Answer: B
Q: left join and in-line view
Product
Product_id Product
1 1001
2 1002
3 1003
Sales
Product_id Sales
3 100
1 200
5 100
1 200
3 100
1 100
Proc sql;
select p.product, s.totalsales
from product as p
left join
(select product_id, sum(sales) as totalsales
from sales
group by product_id) as s
on p.product_id=s.product_id;
quit;
What is the output?
Answer:
Product Totalsales
1001 500
1002 .
1003 200
Q: in-line view
给了一段code 明确告知in-line view 中给定的condition 有
multiply observations satisfied the condition, 问program 运行结果。
Q:
答案是运行出错没有结果,因为in-line view return multiple results.
Ask why program failed,
答案order by statement can't be used inside of an in-line view;
注意干扰项:order by cannot be used in a query where there is an in-line view.
Q: When would it be most efficient to use multiple SET statements in the DATA Step?
A. One file has large amount of rows of data, another one only has small number of data
Index is used as key (这句表述我不太确定) and大的dataset 里有index
B. Both files have large amount of rows of data
Index is used as key
C. One file has large amount of rows of data, another one only has small number of data
Index is NOT used as key
D. Both files have large amount of rows of data
Index is NOT used as key
zwl199464说:我觉得这道题是A 主要是根据set 和 key option 在书中的描述 不过不是很确定 望指正
MZX选了A 不确定。
我也选A了
Q:没给出具体数据,但说了关于这两个数据集的一些限定条件。要选出inactive_date 为missing 时候的observation。题目是
prol sql;
Select *
From dataset1 A
Full join dataset2 B
On A.ID = B.ID
Where inactive_date is missing;
问 data dataset3;
merge dataset1 (In=Ina)
dataset2 (In=Inb);
By ID;
<insert statement>;
选项有 A: where inactive_date is missing and (Ina and Inb)
B: where inactive_date is missing and (Ina or Inb)
C: if inactive_date is missing and (ina and inb)
D: If inactive_date ne .
MZX选择C 不确定
XM (07May2019): 我选了B,就是or那个。因为用的是full join.
我也选的B,题目是full join
感觉这题是有变体的,大家要看好full join还是merge或者其他join方式
Q: 考in line view
proc sql;
create table forecast as
select a.*, b.sales
from actual a, _________
where a.dept=b.dept;
quit;
ANS:
(select avg(revenue) as average
from Budegt
group by 1) b
MZX注释:考的是括号的位置,记清即可
XM (07May2019):里面有干扰项,
select (avg(revenue) as average
from Budegt
group by 1 ) b
还有俩干扰项用的create,比如
(create avg(revenue) as average
from Budegt
group by 1) b
有内容在括号外的可以快速排除,剩下两个(select...)(create…),选 select那个
Version1:什么样的index can only be set up with DATASET procedure.
A: index centiles can be updated.
B: 可以有mutiple index ?
C: index只有numeric ?
D:index 可以包括missing value
MZX选A 不确定
我也选A
|