Q 21
Given the SAS data set WORK.PRODUCTS: ProdId Price ProductType Sales Returns ------ ----- ----------- ----- ------- K12S 95.50 OUTDOOR 15 2 B132S 2.99 CLOTHING 300 10 R18KY2 51.99 EQUIPMENT 25 5 3KL8BY 6.39 OUTDOOR 125 15 DY65DW 5.60 OUTDOOR 45 5 DGTY23 34.55 EQUIPMENT 67 2 The following SAS program is submitted:
data WORK.OUTDOOR WORK.CLOTH WORK.EQUIP; set WORK.PRODUCTS; if Sales GT 30;
if ProductType EQ 'OUTDOOR' then output WORK.OUTDOOR; else if ProductType EQ 'CLOTHING' then output WORK.CLOTH; else if ProductType EQ 'EQUIPMENT' then output WORK.EQUIP; run;
How many observations does the WORK.OUTDOOR data set contain? A. 1 B. 2 C. 3 D. 6 答案:B
本题知识点:IF子集、OUPUT语句
子集IF语句对满足条件的观测输出到正在被创建的数据集中。 Q 22
Which step displays a listing of all the data sets in the WORK library? A. proc contents lib=WORK run; B. proc contents lib=WORK.all;run; C. proc contents data=WORK._all_; run; D. proc contents data=WORK _ALL_; run; 答案:C
本题知识点:PROC CONTENTS过程 默认自动打印最近创建的数据集的描述信息 PROC CONTENTS;RUN;
打印当前目录下的全部数据集的描述信息 PROC CONTENTS DATA=_ALL_;RUN; 打印WORK临时逻辑库下数据集的描述信息 PROC CONTENTS DATA=WORK._ALL_;RUN; Q 23
Which is a valid LIBNAME statement? A. libname \"_SAS_data_library_location_\"; B. sasdata libname \"_SAS_data_library_location_\"; C. libname sasdata \"_SAS_data_library_location_\"; D. libname sasdata sas \"_SAS_data_library_location_\"; 答案:C
本题知识点:LIBNAME定义逻辑库 参考第12题。 Q 24
Given the following raw data records: ----|----10---|----20---|----30 Susan*12/29/1970*10 Michael**6
The following output is desired: Obs employee bdate years 1 Susan 4015 10 2 Michael . 6
Which SAS program correctly reads in the raw data? A. data employees;
infile 'file specification' dlm='*';
input employee $ bdate : mmddyy10. years; run;
B. data employees;
infile 'file specification' dsd='*';
input employee $ bdate mmddyy10. years; run;
C. data employees;
infile 'file specification' dlm dsd;
input employee $ bdate mmddyy10. years; run;
D. data employees;
infile 'file specification' dlm='*' dsd; input employee $ bdate : mmddyy10. years; run; 答案:D
本题知识点:INFILE语句 参考第2题。 Q 25
Given the following code:
proc print data=SASHELP.CLASS(firstobs=5 obs=15); where Sex='M'; run;
How many observations will be displayed? A. 11 B. 15
C. 10 or fewer D. 11 or fewer 答案:D
本题知识点:WHERE子集 计算15-5+1=11个。
WHERE子集的观测最多为11个。 Q 26
Which step sorts the observations of a permanent SAS data set by two variables and stores the sorted observations in a temporary SAS data set? A. proc sort out=EMPLOYEES data=EMPSORT; by Lname and Fname; run;
B. proc sort data=SASUSER.EMPLOYEES out=EMPSORT; by Lname Fname; run;
C. proc sort out=SASUSER.EMPLOYEES data=WORK.EMPSORT; by Lname Fname; run;
D. proc sort data=SASUSER.EMPLOYEES out=SASUSER.EMPSORT; by Lname and Fname; run; 答案:B
本题知识点:永久数据集、临时数据集 逻辑库.成员 逻辑库 数据集
DATA weight; work(默认) 临时的 DATA work.weight; work 临时的 DATA bikes.weight; Bikes 永久的 Q 27
Given the SAS data set WORK.TEMPS: Day Month Temp --- ----- ----
1 May 75 15 May 70 15 June 80 3 June 76 2 July 85 14 July 89
The following program is submitted: proc sort data=WORK.TEMPS; by descending Month Day; run;
proc print data=WORK.TEMPS; run;
Which output is correct? A.
Obs Day Month Temp --- --- ----- ---- 1 2 July 85 2 14 July 89 3 3 June 76 4 15 June 80 5 1 May 75 6 15 May 7 B.
Obs Day Month Temp --- --- ----- ---- 1 1 May 75
2 2 July 85 3 3 June 76 4 14 July 89 5 15 May 70 6 15 June 80 C.
Obs Day Month Temp --- --- ----- ---- 1 1 May 75 2 15 May 70 3 3 June 76 4 15 June 80 5 2 July 85 6 14 July 89 D.
Obs Day Month Temp --- --- ----- ---- 1 15 May 70 2 1 May 75 3 15 June 80 4 3 June 76 5 14 July 89 6 2 July 85 答案:C
本题知识点:BY语句
BY 当使用BY语句时,first.变量与last.变量才有效。 BY语句中变量默认是升序排列的。 DESCENDING(降序)只作用于它后面的第一个变量。 BY语句的排序是按字符的先后顺序排序的。 Q 28 Given the SAS data set WORK.P2000: Location Pop2000 -------- ------- Alaska 626931 Delaware 783595 Vermont 608826 Wyoming 493782 and the SAS data set WORK.P2008: State Pop2008 -------- ------- Alaska 686293 Delaware 873092 Wyoming 532668 The following output is desired: Obs State Pop2000 Pop2008 Difference 1 Alaska 626931 686293 59362 2 Delaware 783595 873092 89497 3 Wyoming 493782 532668 38886 Which SAS program correctly combines the data? A. data compare; merge WORK.P2000(in=_a Location=State) WORK.P2008(in=_b); by State; if _a and _b; Difference=Pop2008-Pop2000; run; B. data compare; merge WORK.P2000(rename=(Location=State)) WORK.P2008; by State; if _a and _b; Difference=Pop2008-Pop2000; run; C. data compare; merge WORK.P2000(in=_a rename=(Location=State)) WORK.P2008(in=_b); by State; if _a and _b; Difference=Pop2008-Pop2000; run; D. data compare; merge WORK.P2000(in=_a) (rename=(Location=State)) WORK.P2008(in=_b); by State; if _a and _b; Difference=Pop2008-Pop2000; run; 答案:C 本题知识点:MERGE语句IN选项、RENAME=选项 MERGE语句可以实现多表横向合并。 MERGE sas-data-set-1 <(data-set-options)> <…sas-data-set-n <(data-set-options)> IN=选项:创建一个标示变量,若当前观测属于某个数据集,标示为1,否则为0。 RENAME=(表达式)选项:在PDV中,对指定的变量更换变量名。 Q 29 The following SAS program is sumbitted: data WORK.INFO; infile 'DATAFILE.TXT'; input @1 Company 20.@25State if State=' ' then input @30 Year; else input @30 City Year; input NumEmployees; run; How many raw data records are read during each iteration of the DATA step? A. 1 B. 2 C. 3 2. @; D. 4 答案:B 本题知识点:指示器 指针控制 相对位置 绝对位置 列 +表达式值 @表达式值(可回跳) 行 / #表达式值(非回跳) 开始列未知,但已知待读取数据前的字符或单词,可用 @’字符或单词’。 指针控制的@放在变量前面,行固定符@放在变量后面。 固定符@与@@的区别: @:用于一个数据行用多个INPUT语句读取,停留到下一个INPUT语句。 @@:用于一个数据行含有多个观测值读取时,停留留到下一个DATA步。 Q 30 You're attempting to read a raw data file and you see the following messages displayed in the SAS Log: NOTE: Invalid data for Salary in line 4 15-23. RULE: ----+----1----+----2----+----3----+----4----+----5-- 4 120104 F 46#30 11MAY1954 33 Employee_Id=120104 employee_gender=F Salary=. birth_date=-2061 _ERROR_=1 _N_=4 NOTE: 20 records were read from the infile 'c:\\employees.dat'. The minimum record length was 33. The maximum record length was 33. NOTE: The data set WORK.EMPLOYEES has 20 observations and 4 variables. What does it mean? A. A compiler error, triggered by an invalid character for the variable Salary. B. An execution error, triggered by an invalid character for the variable Salary. C. The 1st of potentially many errors, this one occurring on the 4th observation. D. An error on the INPUT statement specification for reading the variable Salary. 答案:B 本题知识点:数据错误 数据错误是指数据不适合定义的数据格式,就会出现数据报错。如给数值型变量赋值字符,就会报错。 当出现数据错误时,程序不会中断。 因篇幅问题不能全部显示,请点此查看更多更全内容