当前位置:首页 >> IT认证 >>

SAS-Base认证考试(70真题+答案详解)


SAS Base 认证考试—70 题 SAS 分多个认证种类:base,advanced,clinic 等,但大多需要先通过 base 认证。 但凡这类商业组织提供的考证,基本都是题库型,所以想考过难度并不大。 对于只想拿 SAS 认证的人,如果熟练掌握网上流传甚广的 sas 真题 70 题,通过 base 认证基本就没问题。 Q1 1. The following SAS program is submitted: data WORK.TOTAL; set WORK.SALARY; by Department Gender; if First.<_insert_code_> then Payroll=0; Payroll+Wagerate; if Last.<_insert_code_>; run; The SAS data set WORK.SALARY is currently ordered by Gender within Department. Which inserted code will accumulate subtotals for each Gender within Department? A. Gender B. Department C. Gender Department D. Department Gender 答案:A

本题知识点:自动变量 在 SAS 读取数据时,在 PDV 过程中会产生很多自动变量,在输出的数据集中是不可见的。 ·FIRST.VARIABLE:同一个 BY 变量(组),若新的变量值第一次出现时,其 first.variable 值为 1。 ·LAST.VARIABLE:同一个 BY 变量(组),若新的变量值最后一次出现时,其 last.variable 值为 1。 另外,在 BY 变量右面有多个变量时,先按第一个变量排序,若第一个变量的观测存在重复时,才按第二个 变量排序。

Q2 Given the following raw data records in TEXTFILE.TXT:

1

----|----10---|----20---|----30 John,FEB,13,25,14,27,Final John,MAR,26,17,29,11,23,Current Tina,FEB,15,18,12,13,Final Tina,MAR,29,14,19,27,20,Current The following output is desired: Obs Name Month Status Week1 Week2 Week3 Week4 Week5 1 John FEB Final $13 $25 $14 $27 $11 . $20 . $23

2 John MAR Current 3 Tina FEB Final

$26

$17

$29

$15

$18

$12

$13 $27

4 Tina MAR Current

$29

$14

$19

Which SAS program correctly produces the desired output? A. data WORK.NUMBERS; length Name $ 4 Month $ 3 Status $ 7; infile 'TEXTFILE.TXT' dsd; input Name $ Month $; if Month='FEB' then input Week1 Week2 Week3 Week4 Status $; else if Month='MAR' then input Week1 Week2 Week3 Week4 Week5 Status $; format Week1-Week5 dollar6.; run; proc print data=WORK.NUMBERS; run; B. data WORK.NUMBERS; length Name $ 4 Month $ 3 Status $ 7; infile 'TEXTFILE.TXT' dlm=',' missover; input Name $ Month $; if Month='FEB' then input Week1 Week2 Week3 Week4 Status $; else if Month='MAR' then input Week1 Week2 Week3 Week4 Week5 Status $; format Week1-Week5 dollar6.;

2

run; proc print data=WORK.NUMBERS; run; C. data WORK.NUMBERS; length Name $ 4 Month $ 3 Status $ 7; infile 'TEXTFILE.TXT' dlm=','; input Name $ Month $ @; if Month='FEB' then input Week1 Week2 Week3 Week4 Status $; else if Month='MAR' then input Week1 Week2 Week3 Week4 Week5 Status $; format Week1-Week5 dollar6.; run; proc print data=WORK.NUMBERS; run; D. data WORK.NUMBERS; length Name $ 4 Month $ 3 Status $ 7; infile 'TEXTFILE.TXT' dsd @; input Name $ Month $; if Month='FEB' then input Week1 Week2 Week3 Week4 Status $; else if Month='MAR' then input Week1 Week2 Week3 Week4 Week5 Status $; format Week1-Week5 dollar6.; run; proc print data=WORK.NUMBERS; run; 答案:C 本题知识点:INFILE 语句与指示器@、@@ INFILE filespecification options; 其中,filespecification 用来定义文件, options 给出选择项; ·filespecification 有以下三种形式:

3

①、fileref(文件标志) ②、’filename’(文件名) ③、CARDS 指明输入的数据,紧跟着 CARDS 语句 · 下列选择项(options)可以出现在 INFILE 语句中: ①、COLUMN=variable 或 COL=variable 定义一个变量, 其值是指针所在的当前列位置。 ②、END=variable 定义一个变量, 作为文件结束的标志。 ③、EOF=label 是一个语句标号, 当 INFILE 语句读到文件末尾时, 作为隐含的 GOTO 语句的目标。 ④、LENGHT=variable 定义一个变量, 其值是当前输入数据行的长度。 ⑤、FIRSTOBS=linenumber 要求从指定的行开始读取数据, 而不是从文件的第一个记录开始。 ⑥、OBS=n 指定从一个顺序输入文件中读取数据的最后一个行(即第 1~第 n 行)。一个观察可能占 n 行。 ⑦、DLM= 若分隔符不是空格,则使用 DLM=指定 ⑧、DSD 忽略引号中数值的分隔符;自动将字符数据中的引号去掉;将两个相邻分隔符视为缺失值处理。 ⑨、MISSOVER 阻止 INPUT 进入下一行读取,未赋值变量视为缺失值。 ⑩、TRUNCOVER 与 MISSOVER 相似,但在 COLUMN INPUT 或 FORMATTED INPUT 中使用。

比较 @ 与 @@ 的区别: ·@ 用于 1 个数据行用多个 input 语句读取,停留到下一个 INPUT 语句。 ·@@ 用于 1 个数据行含有多个观测值读取时,停留到下一个 DATA 步。

Q3 The following SAS program is submitted: data WORK.DATE_INFO; Day="01" ; Yr=1960 ; X=mdy(Day,01,Yr) ; run; What is the value of the variable X? A. the numeric value 0 B. the character value "01011960" C. a missing value due to syntax errors D. the step will not compile because of the character argument in the mdy function.

4

答案:A

本题知识点:数据类型的自动转换 在 SAS 中,日期时间是以 1960 年 1 月 1 日 0 时 0 分 0 秒作为起点的。因此,mdy(1,1,1960)=0。 若把日期时间表示为常数时,要使用相应的格式,带单或双引号,在后面紧跟一个 D(日期)、T(时间)、 DT(日期时间)。 在本题中,日期函数的参数应该是数值,若是字符串,会先尝试字符串是否可以转换为数值,这是自动转 换。 自动转换是指系统产生一个临时的变量来完成赋值或运算。当自动转换发生时,会在 LOG 窗口中给出提示。 1)、字符型变量 ->数值型变量 在下面的情况中,VarB 是一个字符型变量,其它是数字型变量。 ·赋值于一个数字型变量,如:VarA=VarB; ·在算术运算中使用,如:VarA=VarB+0; ·与一个数字型变量进行比较,如:if VarB>=VarA; ·在函数中,参数要求数字型变量,如:VarA=sum(VarB,0); 2)、数值型变量 ->字符型变量 在下面的情况中,VarB 是一个数字型变量,其它是字符型变量。 ·赋值于一个字符型变量,如:VarA=VarB; ·在与要求字符的运算符一起使用,如:VarA=''||VarB; ·在函数中,参数要求字符型变量,如:VarA=trim(VarB);

Q4 The Excel workbook REGIONS.XLS contains the following four worksheets: EAST WEST NORTH SOUTH The following program is submitted: libname MYXLS 'regions.xls';

5

Which PROC PRINT step correctly displays the NORTH worksheet? A. proc print data=MYXLS.NORTH;run; B. proc print data=MYXLS.NORTH$;run; C. proc print data=MYXLS.'NORTH'e;run; D. proc print data=MYXLS.'NORTH$'n;run; 答案:D 本题知识点:打印 Excel 的某个工作表的数据 WHAT IS THAT “$” CHARACTER? Looking at SAS Explorer it may be surprising that each dataset written to Excel appears twice, once with the expected name and once with a trailing “$”. Unlike a typical data source, data in an Excel spreadsheet need not be left and top aligned. For this Excel has named ranges which allow data to be placed anywhere inside a spreadsheet. By default SAS reads and writes data from named ranges on spreadsheets, but will also read spreadsheet data directly in the absence of a named range. When a new SAS dataset is created in an Excel library, SAS creates both a spreadsheet and a named range. Each is given the same name, with thespreadsheet denoted by a trailing “$”. In the example at right CLASS is the named range created by the Excel engine and CLASS$ is the spreadsheet created by the Excel engine to hold the named range. Within SAS, the named range is referred to as Wrkbk.CLASS, and the spreadsheet is referenced using the name literal Wrkbk.’CLASS$’n. SAS name literals are name tokens written as strings within quotation marks, followed by the letter n. Name literals allow the use of special characters that are not otherwise allowed in SAS names , like the “$” used by the Excel libname engine to distinguish worksheets from named ranges. For more information see the Recommended Readings. 摘自《De-Mystifying the SAS LIBNAME Engine in Microsoft Excel: A Practical Guide》

Q5 Which statement specifies that records 1 through 10 are to be read from the raw data file customer.txt? A. infile 'customer.txt' 1-10; B. input 'customer.txt' stop@10; C. infile 'customer.txt' obs=10; D. input 'customer.txt' stop=10; 答案:C 本题知识点:INFILE 的选项 FIRSTOBS=常数,要求从指定的行开始读取数据, 而不是从文件的第一个记录开始。 OBS=常数,指定从一个顺序输入文件中读取数据的最后一个行(即第 1~第 n 行)。一个观测可能占 n 行。

6

Q6 After a SAS program is submitted, the following is written to the SAS log: 101 data WORK.JANUARY; 102 set WORK.ALLYEAR(keep=product month num_Sold Cost); 103 if Month='Jan' then output WORK.JANUARY; 104 Sales=Cost * Num_Sold; 105 keep=Product Sales; ----22 ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, , <=, <>, =, >, >=, AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=, |, ||, ~=. 106 run; What changes should be made to the KEEP statement to correct the errors in the LOG? A. keep=(Product Sales); B. keep Product, Sales; C. keep=Product, Sales; D. keep Product Sales; 答案:D 本题知识点:KEEP 语句与 KEEP=选项 在处理大型数据集时,KEEP=选项的效率较高。 ·KEEP 语句:KEEP variable(s); 不能用于过程步。 ·KEEP=选项:data-set-name( KEEP=variable(s) ) 可以用于数据步(如,DATA 语句、SET 语句)、过程步。 其中,variable(s)是具体变量,不能是数组、_N_、_ERROR_等。

Q7

7

Which of the following choices is an unacceptable ODS destination for producing output that can be viewed in Microsoft Excel? A. MSOFFICE2K B. EXCELXP C. CSVALL D. WINXP 答案:D 本题知识点:ODS 输出 Most of these destinations are designed to create output for viewing on a screen or for printing. The OUTPUT destination creates SAS data sets. The MARKUP destination is a general purpose tool for creating output in formats defined by tagsets. This includes XML (eXtensible Markup Language), EXCELXP, LaTeX, CSV (comma-separated values), and many other formats where data can be thought of as separated by tags. The DO CUMENT destination, on the other hand, allows you to create a reusable output “document” that yo u can rerender for any destination. So, if your boss decides he really wants that report in PDF, not RTF, you can replay the output document without having to rerun the entire SAS program that created the data. With an output document, you can also rearrange, duplicate, or delete tables to further customize your output. 摘自《The Little SAS Book》(Fourth) P152 页

Q8 The SAS data set named WORK.SALARY contains 10 observations for each department, and is currently ordered by Department. The following SAS program is submitted: data WORK.TOTAL; set WORK.SALARY(keep=Department MonthlyWageRate); by Department; if First.Department=1 then Payroll=0; Payroll+(MonthlyWageRate*12); if Last.Department=1; run; Which statement is true? A. The by statement in the DATA step causes a syntax error. B. The statement Payroll+(MonthlyWageRate*12); in the data step causes a syntax error.

8

C. The values of the variable Payroll represent the monthly total for each department in the WORK.SALARY data set. D. The values of the variable Payroll represent a monthly total for all values of WAGERATE in the WORK.SALARY data set. 答案:C 本题知识点:类似第 1 题

Q9 data course; input exam; datalines; 50.1 ; run; proc format; value score 1 – 50 = ‘Fail’ 51 – 100 = ‘Pass’; run; proc report data =course nowd; column exam; define exam / display format=score.; run; What is the value for exam? A. Fail B. Pass C. 50.1 D. No output 答案:C 本题知识点:PROC FORMAT 语句 PROC FORMAT; VALUE name range-1=’formatted-text-1′; range-2=’formatted-text-2′; …… range-n=’formatted-text-n’;

9

若 name 为字符串设计格式,则必须在开头加$,长度不超过 32 字节; name 不能以数字结尾,除了下划线外,不能含其他的任何特殊字符。 在 range 右侧文本可达到 32767 字节。 ·变量值是字符串要加引号。 ·range 是多个值,要用逗号。 ·连续的要用-。 ·关键字 low、high 指代变量中最小和最大的非缺失值。 ·用<排除或指代某些范围。 ·other 是给其他没列在 VALUE 中的变量分配格式。

Q 10 The following SAS program is submitted: data WORK.RETAIL; Cost='$20.000'; Discount=.10*Cost; run; What is the result? A. The value of the variable Discount in the output data set is 2000. No messages are written to the SAS log. B. The value of the variable Discount in the output data set is 2000. A note that conversion has taken place is written to the SAS log. C. The value of the variable Discount in the output data set is missing. A note in the SAS log refers to invalid numeric data. D. The variable Discount in the output data set is set to zero. No messages are written to the SAS log. 答案:C 本题知识点:标准数据、以及数据类型的自动转换 非标准数据 ·含逗号的数值,如:1,00,001; ·包含美元符号、十六进制、压缩十进制的数据; ·日期是最普通的非标准数据。 标准数据

10

·数字 0-9 ·英文句号 ·科学计数、E ·+、如果字符型变量转换后不能作为标准数值读入,被转换成的字符型变量有格式要求,必须进行显式转换。

Q 11 Given the existing SAS program: proc format; value agegrp low-12 ='Pre-Teen' 13-high = 'Teen'; run; proc means data=SASHELP.CLASS; var Height; class Sex Age; format Age agegrp.; run; Which statement in the proc means step needs to be modified or added to generate the following results: Analysis Variable : Height N Sex Age Obs Minimum Maximum Mean -----------------------------------------------------------------F Pre-Teen 3 51.3 59.8 55.8 Teen 6 56.5 66.5 63.0 M Pre-Teen 4 57.3 64.8 59.7 Teen 6 62.5 72.0 66.8 -------------------------------------------------------------------A. var Height / nobs min max mean maxdec=1; B. proc means data=SASHELP.CLASS maxdec=1 ; C. proc means data=SASHELP.CLASS min max mean maxdec=1; D. output nobs min max mean maxdec=1; 答案:C 本题知识点:PROC MEANS 过程 PROC MEANS <options><statistic-keywords>; 语句; RUN; ? <options> data=:数据集 maxdec=:指定输出结果的小数位数,默认为 7 位 noprint:禁止结果在 OTPUT 窗口输出 alpha:设定可信区间的 α 水平,默认为 0.05 ? <statistic-keywords> MAX、MIN、MEAN、MEDIAN、N、NMISS、RANGE、STDDEV、SUM

11

若不加统计关键词,默认打印的顺序: 非缺失值个数(N)、均值(MEAN)、标准差(STDDEV)、最小值(MIN)、最大值(MAX)。 ? 语句 若在 PROC MEAN 过程中没有其他语句,默认输出所有观测值和所有数值变量的统计量。 BY:分变量单独分析,数据必须先按变量顺序排序,即 PROC SORT CLASS:分变量单独分析,不用排序 VAR:指定使用的数值变量 Q 12 The Excel workbook QTR1.XLS contains the following three worksheets: JAN FEB MAR Which statement correctly assigns a library reference to the Excel workbook? A. libname qtrdata 'qtr1.xls'; B. libname 'qtr1.xls' sheets=3; C. libname jan feb mar 'qtr1.xls'; D. libname mydata 'qtr1.xls' WORK.heets=(jan,feb,mar); 答案:A 本题知识点:LIBNAME 语句格式 LIBNAME libref <engine> ‘SAS-data-library’ < options ><engine/host-options>; Q 13 The following SAS program is submitted: data WORK.TEST; set WORK.MEASLES(keep=Janpt Febpt Marpt); array Diff{3} Difcount1-Difcount3; array Patients{3} Janpt Febpt Marpt; run; What new variables are created? A. Difcount1, Difcount2 and Difcount3 B. Diff1, Diff2 and Diff3 C. Janpt, Febpt, and Marpt D. Patients1, Patients2 and Patients3 答案:A 本题知识点:数组 与其他编程语言的数组相比不同在于,SAS 数组的每个元素都对应一个变量名。 ? 数值型数组 数组说明中的初始值可省略,默认为缺失值。 数组说明中变量可省略,变量名默认为数组名+序号。序号从 1 开始。 ARRAY test(3) Math Chinese English (0,0,0); 数组元素的个数由变量个数决定。 ARRAY test(*) test3-test8; 二维数组,数组元素按行排列。 ARRAR x(2,2) x11 x12 x21 x22; ? 字符型数组

12

字符型数组药指定数组元素的最大长度,其他与数值型数组相同。 ARRAY test(2) $ 10 mathor father; ? 临时数组 若 SAS 数组每个元素不对应变量名,即为临时数组。这与其他编程语言相同。 ARRAY test(3) _TEMPORARY_ (0,0,0); 临时数组只用于中间计算,不保存入数据集。 在数据步中,临时数组在数据步隐含循环中能自动保留上一步得到的值。 Q 14 Which of the following programs correctly invokes the DATA Step Debugger: A. data WORK.TEST debug; set WORK.PILOTS; State=scan(cityState,2,' '); if State='NE' then description='Central'; run; B. data WORK.TEST debugger; set WORK.PILOTS; State=scan(cityState,2,' '); if State='NE' then description='Central'; run; C. data WORK.TEST / debug; set WORK.PILOTS; State=scan(cityState,2,' '); if State='NE' then description='Central'; run; D. data WORK.TEST / debugger; set WORK.PILOTS; State=scan(cityState,2,' '); if State='NE' then description='Central'; run; 答案:C 本题知识点: / debug 语法 DEBUG 过程的调用方法:在 DATA 步后面增加 DEBUG 选项。 Q 15 Which statement is true concerning the SAS automatic variable _ERROR_? A. It cannot be used in an if/then condition. B. It cannot be used in an assignment statement. C. It can be put into a keep statement or keep= option. D. It is automatically dropped. 答案:D 本题知识点:自动变量_ERROR_ 在 PDV 过程中,产生很多自动变量,可以在数据步的表达式中使用,在输出数据集中不可见。 在 PDV 过程中,_N_、_ERROR_默认为 DROP。 在 KEEP 语句或 KEEP=选项中,可以使用除了_N_、_ERROR_之外的变量。 Q 16 The following SAS program is submitted: data WORK.DATE_INFO; X='04jul2005'd;

13

DayOfMonth=day(x); MonthOfYear=month(x); Year=year(x); run; What types of variables are DayOfMonth, MonthOfYear, and Year? A. DayOfMonth, Year, and MonthOfYear are character. B. DayOfMonth, Year, and MonthOfYear are numeric. C. DayOfMonth and Year are numeric. MonthOfYear is character. D. DayOfMonth, Year, and MonthOfYear are date values. 答案:B 本题知识点:SAS 中日期时间及函数 起点:1960 年 1 月 1 日 0 时 0 分 0 秒。 若将日期时间标示为数值型常数,需使用相应格式。 格式值带单引号,后跟一个 D(日期)、T(时间)、DT(日期时间)。 日期函数返回值为数值。 Q 17 Given the following data step: data WORK.GEO; infile datalines; input City $20.; if City='Tulsa' then State='OK'; Region='Central'; if City='Los Angeles' then State='CA'; Region='Western'; datalines; Tulsa Los Angeles Bangor ; run; After data step execution, what will data set WORK.GEO contain? A. City State Region ----------- ----- ------Tulsa OK Western Los Angeles CA Western Bangor Western B. City State Region ----------- ----- ------Tulsa OK Western Los Angeles CA Western Bangor C. City State Region ----------- ----- ------Tulsa OK Central Los Angeles CA Western Bangor Western D. City State Region ----------- ----- ------Tulsa OK Central Los CA Western Bangor

14

答案:A 本题知识点:IF 语句 若执行语句不能在一个语句完成,则使用复合语句 DO 和 END IF 条件 THEN 语句; 没有 ENDIF,没有 IF-ELSEIF-ELSE 多分支结构,语句 1 只能是一个语句。 IF 条件 THEN 语句 1; <ELSE 语句 2>; Q 18 Which statement describes a characteristic of the SAS automatic variable _ERROR_? A. The _ERROR_ variable maintains a count of the number of data errors in a DATA step. B. The _ERROR_ variable is added to the program data vector and becomes part of the data set being created. C. The _ERROR_ variable can be used in expressions in the DATA step. D. The _ERROR_ variable contains the number of the observation that caused the data error. 答案:C 本题知识点:WHERE 语句 类似第 15 题。 Q 19 The SAS data set WORK.ONE contains a numeric variable named Num and a character variable named Char: WORK.ONE Num Char --- ---1 23 3 23 1 77 The following SAS program is submitted: proc print data=WORK.ONE; where Num='1'; run; What is output? A. Num Char --- ---1 23 B. Num Char --- ---1 23 1 77 C. Num Char --- ---1 23 3 23 1 77 D. No output is generated. 答案:D 本题知识点:WHERE 语句 WHERE 语句无法找到满足条件的观测。 Q 20

15

The data set WORK.REALESTATE has the variable LocalFee with a format of 9. and a variable CountryFee with a format of 7.; The following SAS program is submitted: data WORK.FEE_STRUCTURE; format LocalFee CountryFee percent7.2; set WORK.REALESTAT; LocalFee=LocalFee/100; CountryFee=CountryFee/100; run; What are the formats of the variables LOCALFEE and COUNTRYFEE in the output dataset? A. LocalFee has format of 9. and CountryFee has a format of 7. B. LocalFee has format of 9. and CountryFee has a format of percent7.2 C. Both LocalFee and CountryFee have a format of percent7.2 D. The data step fails execution; there is no format for LocalFee. 答案:C 本题知识点:FORMAT 语句 FORMAT 语句为非执行语句。FORMAT 语句在 SET 语句前后均无差别。 FORMAT 可以使用在数据步和过程步中,前者把格式永久存储,后者只是临时存储(当前过程中有作用)。 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;

16

答案: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 题。

17

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;

18

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 <DESCENDING> variable-1 <…<DESCENDING variablen> <NOTSORTED> <GROUPFORMAT> 当使用 BY 语句时,first.变量与 last.变量才有效。 BY 语句中变量默认是升序排列的。 DESCENDING(降序)只作用于它后面的第一个变量。 BY 语句的排序是按字符的先后顺序排序的。 Q 28 Given the SAS data set WORK.P2000: Location Pop2000 -------- ------Alaska 626931

19

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-setoptions)> <END=variable>; IN=选项:创建一个标示变量,若当前观测属于某个数据集,标示为 1,否则为 0。 RENAME=(表达式)选项:在 PDV 中,对指定的变量更换变量名。 Q 29 The following SAS program is sumbitted: data WORK.INFO;

20

infile 'DATAFILE.TXT'; input @1 Company $20. @25 State $2. @; 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 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 本题知识点:数据错误 数据错误是指数据不适合定义的数据格式,就会出现数据报错。如给数值型变量赋值字符,就会报错。 当出现数据错误时,程序不会中断。 Q 31 Given the following raw data records in DATAFILE.TXT: ----|----10---|----20---|----30 Kim,Basketball,Golf,Tennis Bill,Football Tracy,Soccer,Track The following program is submitted: data WORK.SPORTS_INFO; length Fname Sport1-Sport3 $ 10; infile 'DATAFILE.TXT' dlm=',';

21

input Fname $ Sport1 $ Sport2 $ Sport3 $; run; proc print data=WORK.SPORTS_INFO; run; Which output is correct based on the submitted program? A. Obs Fname Sport1 Sport2 Sport3 1 Kim Basketball Golf Tennis 2 Bill Football 3 Tracy Soccer Track B. Obs Fname Sport1 Sport2 Sport3 1 Kim Basketball Golf Tennis 2 Bill Football Football Football 3 Tracy Soccer Track Track C. Obs Fname Sport1 Sport2 Sport3 1 Kim Basketball Golf Tennis 2 Bill Football Tracy Soccer D. Obs Fname Sport1 Sport2 Sport3 1 Kim Basketball Golf Tennis 2 Bill Football 答案:C 本题知识点:INFILE 语句选项 MISSOVER 参考第 5 题。 Q 32 Consider the following data step: data WORK.NEW; set WORK.OLD; Count+1; run; The variable Count is created using a sum statement. Which statement regarding this variable is true? A. It is assigned a value 0 when the data step begins execution. B. It is assigned a value of missing when the data step begins execution. C. It is assigned a value 0 at compile time. D. It is assigned a value of missing at compile time. 答案:C 本题知识点:累加语句 variable + expression; 等价于 retain varibale 0; vaiable=variable+1; 变量必须是数值类型,初始值只能是 0。 x+1; x+(-1); /*每次执行减少 1,不能写成 x-1*/ x+(y=z); /*若 y=z,返回 1,则 x 累加 1,否则不累加*/ 在实际中,一般使用 retain 语句代替累加语句。retain 语句的初始值可以是一个非零值。 Q 33 The following SAS program is submitted:

22

data WORK.TEST; set WORK.PILOTS; if Jobcode='Pilot2' then Description='Senior Pilot'; else Description='Unknown'; run; The value for the variable Jobcode is: PILOT2. What is the value of the variable Description? A. PILOT2 B. Unknown C. Senior Pilot D. ' ' (missing character value) 答案:B 本题知识点:SAS 中的大小写 在 SAS 中,语句是不区分大小写的,但是字符型变量的数据值是区分大小写的。 Q 34 A user-defined format has been created using the FORMAT procedure. How is it stored? A. in a SAS catalog B. in a memory resident lookup table C. in a SAS dataset in the WORK library D. in a SAS dataset in a permanent SAS data library 答案:A 本题知识点:PROC FORMAT 过程中格式存储位置 FORMAT 过程在编译后,存储在 Work.Formats、Sasuser.Format 目录中。 Q 35 Given the SAS data set SASDATA.TWO: X Y -- -5 2 3 1 5 6 The following SAS program is submitted: data SASUSER.ONE SASUSER.TWO OTHER; set SASDATA.TWO; if X eq 5 then output SASUSER.ONE; if Y lt 5 then output SASUSER.TWO; output; run; What is the result? A. data set SASUSER.ONE has 5 observations data set SASUSER.TWO has 5 observations data set WORK.OTHER has 3 observations B. data set SASUSER.ONE has 2 observations data set SASUSER.TWO has 2 observations data set WORK.OTHER has 1 observations C. data set SASUSER.ONE has 2 observations data set SASUSER.TWO has 2 observations data set WORK.OTHER has 5 observations D. No data sets are output. The DATA step fails execution due to syntax errors.

23

答案:A 本题知识点:OUTPUT 语句输出到多个数据集 在一个数据步中,创建不同数据集 DATA data-set1 data-set2 data-set3; 在每一个数据步的结尾都有一个暗含的 OUTPUT 语句,它告诉 SAS 处理下一个观测值前,把当前观测写入输 出数据集中。 若自定义使用 OUTPUT 语句,默认的 OUTPUT 语句就不存在。 OUTPUT data-set-name; 若省略数据集名,则将数据步中所有数据集都将被写入数据。 OUTPUT 语句可单独使用,也可与 IF-THEN 或 DO-LOOP 过程中。 Q 36 Given the contents of the raw data file 'EMPLOYEE.TXT': ----+----10---+----20---+----30-Xing 2 19 2004 ACCT Bob 5 22 2004 MKTG Jorge 3 14 2004 EDUC The following SAS program is submitted: data WORK.EMPLOYEE; infile 'EMPLOYEE.TXT'; input @1 FirstName $ @15 StartDate @25 Department $; run; Which SAS informat correctly completes the program? A. date9. B. mmddyy10. C. ddmmyy10. D. mondayyr10. 答案:B 本题知识点:日期时间格式 DATEw.读取 ddmmmyy 或 ddmmmyyyy 形式的日期值,mmm 指月份的英文缩写,w 默认为 7 列。 TIMEw.读取 hh:mm:ss.ss 形式的时间值,如 08:25:30.7 DATETIMEw.读取 ddmmyyhh:mm:ss.ss 形式的日期时间值,如 15Oct84:8:25:30.7 或 15Oct1984/8:25:30.7 DDMMYYw.读取 ddmmyy 形式的日期值 MMDDYYw.读取 mmddyy 形式的日期值 YYMMDDw.读取 yymmdd 形式的日期值 Q 37 The SAS data set Fed.Banks contains a variable Open_Date which has been assigned a permanent label of "Open Date". Which SAS program temporarily replaces the label "Open Date" with the label "Starting Date" in the output? A. proc print data=SASUSER.HOUSES label; label Open_Date "Starting Date"; run; B. proc print data=SASUSER.HOUSES label; label Open_Date="Starting Date"; run; C. proc print data=SASUSER.HOUSES; label Open_Date="Starting Date"; run; D. proc print data=SASUSER.HOUSES;

24

Open_Date="Starting Date"; run; 答案:B 本题知识点:LABEL 语句 PROC PRINT DATA=WORK.TEST LABEL; LABEL variable=”标签内容”; RUN; Q 38 Given the SAS data set WORK.ONE: X Y Z - - -1 A 27 1 A 33 1 B 45 2 A 52 2 B 69 3 B 70 4 A 82 4 C 91 The following SAS program is submitted: data WORK.TWO; set WORK.ONE; by X Y; if First.Y; run; proc print data=WORK.TWO noobs; run; Which report is produced? A. X Y Z -- -- -1 B 45 2 A 52 2 B 69 3 B 70 4 A 82 4 C 91 B. X Y Z -- -- -1 A 27 1 B 45 2 A 52 2 B 69 3 B 70 4 A 82 4 C 91 C. X Y Z -- -- -1 A 33 1 B 45 2 A 52

25

2 B 69 3 B 70 4 A 82 4 C 91 D. The PRINT procedure fails because the data set WORK.TWO is not created in the DATA step. 答案:B 本题知识点:FIRST 变量 参考第 1 题。 Q 39 The following SAS program is submitted: data WORK.AUTHORS; array Favorites{3} $ 8 ('Shakespeare','Hemingway','McCaffrey'); run; What is the value of the second variable in the dataset WORK.AUTHORS? A. Hemingway B. Hemingwa C. ' ' (a missing value) D. The program contains errors. No variables are created. 答案:B 本题知识点:数组 参考第 13 题。 Q 40 The following SAS program is submitted: data WORK.PRODUCTS; Prod=1; do while(Prod LE 6); Prod + 1; end; run; What is the value of the variable Prod in the output data set? A. 6 B. 7 C. 8 D. . (missing numeric) 答案:B 本题知识点:WHILE 语句 DO WHILE 循环继续条件; 循环体语句; END; DO UNTIL 循环退出条件; 循环体语句; /*至少执行一次*/ RUN; 在退出循环后,注意下标变量的数值。 Q 41 Given the raw data record in the file phone.txt: ----|----10---|----20---|----30---| Stevens James SALES 304-923-3721 14 The following SAS program is submitted:

26

data WORK.PHONES; infile 'phone.txt'; input EmpLName $ EmpFName $ Dept $ Phone $ Extension; <_insert_code_> run; Which SAS statement completes the program and results in a value of "James Stevens" for the variable FullName? A. FullName=CATX(' ',EmpFName,EmpLName); B. FullName=CAT(' ',EmpFName,EmpLName); C. FullName=EmpFName!!EmpLName; D. FullName=EmpFName + EmpLName; 答案:A 本题知识点:CAT 系列函数 cat(of x1-x4):即 x1||x2||x3||x4 catt(of x1-x4):即 trim(x1)||trim(x2)||trim(x3)||trim(x4) cats(of x1-x4):即 trim(left(x1))||trim(left(x2))||trim(left(x3))||trim(left(x4)) catx(sp,of x1-x4):即 trim(left(x1))||sp||trim(left(x2))||sp||trim(left(x3))||sp||trim(left(x4)) 为什么没有选 C。从理解上,应该正确。但是,实际上是不对的。这正是 SAS 编程与其他语言的差异之 一。 查看变量长度,可以发现,没有 LENGTH 语句申明长度时,默认每个变量(无论数值型或字符型)读取 的长度都是 8,不足的以空格填充。 proc contents data=WORK.PHONES varnum; run; 选项 C 的结果为 FullName=’James Stevens‘,中间是空格是 3 个空格,即 James_ _ _ Stevens_ Q 42 The following SAS program is submitted: data WORK.ONE; Text='Australia, US, Denmark'; Pos=find(Text,'US','i',5); run; What value will SAS assign to Pos? A. 0 B. 1 C. 2 D. 12 答案:D 本题知识点:字符串查找函数:FIND 函数 FIND(string,substring<,modifiers><,startpos>) FIND(string,substring<,startpos><,modifiers>) 返回 substring 在原字符串 string 中的位置。 modifiers 参数:’i'是忽略大小写;’t'是去掉 string,substring 的空格。 Q 43 Given the SAS data set WORK.ORDERS: WORK.ORDERS order_id customer shipped -------- ------------ --------9341 Josh Martin 02FEB2009 9874 Rachel Lords 14MAR2009 10233 Takashi Sato 07JUL2009

27

The variable order_id is numeric; customer is character; and shipped is numeric, contains a SAS date value, and is shown with the DATE9. format. A programmer would like to create a new variable, ship_note, that shows a character value with the order_id, shipped date, and customer name. For example, given the first observation ship_note would have the value "Order 9341 shipped on 02FEB2009 to Josh Martin". Which of the following statement will correctly create the value and assign it to ship_note? A. ship_note=catx(' ','Order',order_id,'shipped on',input(shipped,date9.),'to',customer); B. ship_note=catx(' ','Order',order_id,'shipped on',char(shipped,date9.),'to',customer); C. ship_note=catx(' ','Order',order_id,'shipped on',transwrd(shipped,date9.),'to',customer); D. ship_note=catx(' ','Order',order_id,'shipped on',put(shipped,date9.),'to',customer); 答案:D 本题知识点:CAT 系列函数、变量数据类型的显式转换 CAT 系列函数,参考第 41 题。 如果字符型变量转换后不能作为标准数值读入,被转换成的字符型变量有格式要求,必须进行显式转换。 1)、字符型变量 ->数值型变量 INPUT(source,informat) 其中,source 是被转换的字符型变量,informat 是读取数字型变量的输入格式。 2)、数值型变量 ->字符型变量 PUT(source,format) 其中,source 是被转换的数字型变量,format 是一个输出格式。

Q 44 The following SAS program is submitted: data ONE TWO SASUSER.TWO set SASUSER.ONE; run; Assuming that SASUSER.ONE exists, how many temporary and permanent SAS data sets are created? A. 2 temporary and 1 permanent SAS data sets are created B. 3 temporary and 2 permanent SAS data sets are created C. 2 temporary and 2 permanent SAS data sets are created D. there is an error and no new data sets are created 答案:D 本题知识点:永久数据集、临时数据集 参考第 26 题。但此题 DATA 语句缺少分号,存在语法错误。 Q 45 The following SAS program is submitted: ods csvall file='c:\test.cvs'; proc print data=WORK.ONE; var Name Score Grade; by IdNumber; run; ods csvall close; What is produced as output? A. A file named test.cvs that can only be opened in Excel. B. A text file named test.cvs that can be opened in Excel or in any text editor. C. A text file named test.cvs that can only be opened in a text editor. D. A file named test.cvs that can only be opened by SAS. 答案:C

28

本题知识点:CSV 的打开问题 CSV 是一种用来存储数据的纯文本文件,通常都是用于存放电子表格或数据的一种文件格式。 CSV 文件格式只能保存活动工作表中的单元格所显示的文本和数值。数据列以逗号分隔,每一行数据都以 回车符结束。 ? 如果单元格中包含逗号,则该单元格中的内容以双引号引起。 ? 如果单元格显示的是公式而不是数值,该公式将转换为文本方式。 ? 所有格式、图形、对象和工作表的其他内容将全部丢失。 ? 欧元符号将转换为问号。 用记事本和 excel、Editplus 等文本编辑器都能打开。记事本打开显示逗号;excel 打开,没有逗号。 本题也是很多人讨论答案,其实是没有仔细读题。 注意题目中说得是后缀为*.CVS 的文件,这个是 SAS 自定义的文本文件格式,答案也选 B。 如果是后缀为*.CSV 的文件,答案就是 B。 Q 46 Given the SAS data set WORK.ONE: Obs Revenue2008 Revenue2009 Revenue2010 ------------- ----------- ----------1 1.2 1.6 2.0 The following SAS program is submitted: data WORK.TWO; set WORK.ONE; Total=mean(of Rev:); run; What value will SAS assign to Total? A. 3 B. 1.6 C. 4.8 D. The program fails to execute due to errors. 答案:B 本题知识点:变量列表 变量列表 X1、X2、……、Xn Xa、Xb、……、Xy X、Y、Z、A 缩写 X1-Xn X: X-A X_NUMERIC_A X_CHARACTER_A 说明 X1~Xn 的所有变量 所有 X 开头的变量 X~A 的所有变量 X~A 的所有数值型变量 X~A 的所有字符型变量

Q 47 The following output is created by the FREQUENCY procedure: The FREQ Procedure Table of region by product region product Frequency| Percent | Row Pct | Col Pct |corn |cotton |oranges | Total ---------+--------+--------+--------+ EAST | 2 | 1| 1| 4 | 22.22 | 11.11 | 11.11 | 44.44

29

| 50.00 | 25.00 | 25.00 | | 50.00 | 33.33 | 50.00 | ---------+--------+--------+--------+ SOUTH | 2 | 2| 1| 5 | 22.22 | 22.22 | 11.11 | 55.56 | 40.00 | 40.00 | 20.00 | | 50.00 | 66.67 | 50.00 | ---------+--------+--------+--------+ Total 4 3 2 9 44.44 33.33 22.22 100.00 Which TABLES option(s) would be used to eliminate the row and column counts and just see the frequencies and percents? A. norowcount nocolcount B. freq percent C. norow nocol D. nocounts 答案:C 本题知识点:PROC FREQ 过程 对一个变量计算频数叫 one-way,两个叫 two-way,多个叫交叉表。 PROC FREQ; TABLE variale-combinations; 在语句后面,可以使用的选项主要有: ? LIST:用 list 的方式打印交叉表,而不是表格 ? MISSING:概率统计量中包含缺失值 ? NOCOL:强制在交叉表中不打印列百分比 ? NOROW:强制在交叉表中不打印行百分比 ? OUTPUT=data-set Q 48 The following SAS program is submitted: data WORK.TEST; drop City; infile datalines; input Name $ 1-14 / Address $ 1-14 / City $ 1-12 ; if City='New York ' then input @1 State $2.; else input; datalines; Joe Conley 123 Main St. Janesville WI Jane Ngyuen 555 Alpha Ave. New York NY Jennifer Jason 666 Mt. Diablo Eureka CA ;

30

What will the data set WORK.TEST contain? A. Name Address State -------------- ---------------- -----Joe Conley 123 Main St. Jane Ngyuen 555 Alpha Ave. NY Jennifer Jason 666 Mt. Diablo B. Name Address City State -------------- ---------------- ----------- -----Joe Conley 123 Main St. Janesville Jane Ngyuen 555 Alpha Ave. New York NY Jennifer Jason 666 Mt. Diablo Eureka C. Name Address State -------------- ---------------- -----Jane Ngyuen 555 Alpha Ave. NY D. 0 observations,there is a syntax error in the data step. 答案:A 本题知识点:指示器@ 参考第 29 题。 Q 49 The following SAS program is submitted: data WORK.TOTALSALES(keep=MonthSales{12}); set WORK.MONTHLYSALES(keep=Year Product Sales); array MonthSales{12}; do i=1 to 12; MonthSales{i}=Sales; end; drop i; run; The program fails execution due to syntax errors. What is the cause of the syntax error? A. An array cannot be referenced on a keep= data set option. B. The keep= data set option should be (keep=MonthSales*). C. The keep= data set option should be the statement KEEP MonthSales{12}. D. The variable MonthSales does not exist. 答案:A 本题知识点:KEEP=选项 参考第 6 题。 Q 50 Given the SAS data set WORK.ONE: Id Char1 --- ----111 A 158 B 329 C 644 D and the SAS data set WORK.TWO: Id Char2 --- -----

31

111 E 538 F 644 G The following program is submitted: data WORK.BOTH; set WORK.ONE WORK.TWO; by Id; run; What is the first observation in SAS data set WORK.BOTH? A. Id Char1 Char2 --- ----- ----111 A B. Id Char1 Char2 --- ----- ----111 E C. Id Char1 Char2 --- ----- ----111 A E D. Id Char1 Char2 --- ----- ----644 D G 答案:A 本题知识点:SET 纵向合并数据集 ? SET 组合数据集 把一个数据集合并在另一个数据集后面,适用于两个变量相同的数据集。 先指定新数据集,再列出需要合并的旧数据集。 DATA new-data-set; SET data-set1 data-set-n; 若一个数据集中包含了另一个数据集没有的变量,该变量在合并后为缺失值。 ? SET 插入数据集 在 SET 语句中使用 BY,可按顺序合并。 DATA new-data-set; SET data-set1 data-set-n; BY variable-list; 在几个数据集合并前,每个数据集都要用 BY 排序,或 PROC SORT 排序。 Q 51 The following program is submitted: proc contents data=_all_; run; Which statement best describes the output from the submitted program? A. The output contains only a list of the SAS data sets that are contained in the WORK library. B. The output displays only the contents of the SAS data sets that are contained in the WORK library. C. The output displays only the variables in the SAS data sets that are contained in the WORK library. D. The output contains a list of the SAS data sets that are contained in the WORK library and displays the contents of those data sets. 答案:D

32

本题知识点:PROC COTENTS 过程 参考第 22 题。 Q 52 Given the SAS data set WORK.EMP_NAME: Name EmpID ---- ----Jill 1864 Jack 2121 Joan 4698 John 5463 Given the SAS data set WORK.EMP_DEPT: EmpID Department ----- ---------2121 Accounting 3567 Finance 4698 Marketing 5463 Accounting The following program is submitted: data WORK.ALL; merge WORK.EMP_NAME(in=Emp_N) WORK.EMP_DEPT(in=Emp_D); by Empid; if (Emp_N and not Emp_D) or (Emp_D and not Emp_N); run; How many observations are in data set WORK.ALL after submitting the program? A. 1 B. 2 C. 3 D. 5 答案:B 本题知识点:MERGE 合并数据集、IF 子集 找出两个数据集中不重合的观测个数。 Q 53 The following SAS program is submitted: data WORK.TOTAL_SALARY; retain Total; set WORK.SALARY; by Department; if First.Department then Total=0; Total=sum(Total, Wagerate); if Last.Total; run; What is the initial value of the variable Total? A. 0 B. Missing C. The value of the first observations Wagerate D. Cannot be determined from the information given 答案:B 本题知识点:RETAIN 语句

33

retain 语句是非执行语句。 retain; /*针对所有变量*/ retain x y; retain x1-x5; retain x1-x5 1 0 a b ‘abc’; retain x1-x5(1); /*x1=1,其余为缺失值*/ retain x1-x4(1 2 3 4); retain x1-x4(1:4); array arr(2) x y;retain arr; Q 54 Consider the following data step: data WORK.TEST; set SASHELP.CLASS(obs=5); retain City 'Beverly Hills'; State='California'; run; The computed variables City and State have their values assigned using two different methods, a RETAIN statement and an Assignment statement. Which statement regarding this program is true? A. The RETAIN statement is fine, but the value of City will be truncated to 8 bytes as the LENGTH statement has been omitted. B. Both the RETAIN and assignment statement are being used to initialize new variables and are equally efficient. Method used is a matter of programmer preference. C. The assignment statement is fine, but the value of City will be truncated to 8 bytes as the LENGTH statement has been omitted. D. City's value will be assigned one time, State's value 5 times. 答案:D 本题知识点:RETAIN 语句 一般,SAS 每读一遍 DATA 步的所有语句,PDV 清空所有所有变量值,并设置为缺失值。再执行 INPUT 语句 或赋值语句,再次对变量赋值。 如果在 DATA 步中使用 RETAIN 语句,不会清空 RETAIN 对应的变量,保留到该变量下次再次被执行。 Q 55 The following SAS program is submitted: data WORK.DATE_INFO; X="01Jan1960" D ; run; Variable X contains what value? A. the numeric value 0 B. the character value "01Jan1960" C. the date value 01011960 D. the code contains a syntax error and does not execute. 答案:D 本题知识点:日期时间的表示格式 起点:1960 年 1 月 1 日 0 时 0 分 0 秒。 若将日期时间标示为数值型常数,需使用相应格式。 格式值带单引号,后紧跟跟一个 D(日期)、T(时间)、DT(日期时间)。 在表示为数值常数时,不支持 MMDDYYw.格式,支持 datew.格式。 本题,答案 C,是因为 X="01Jan1960" D ;中 D 之前有个空格。 若改为 X="01Jan1960"D ; ,答案就是 A。 若改为 X="01011960"D ; ,答案就是 D。 Q 56

34

The following output is created by the FREQUENCY procedure: The FREQ Procedure Table of region by product region product Frequency| Percent | Row Pct | Col Pct |corn |cotton |oranges | Total ---------+--------+--------+--------+ EAST | 2 | 1| 1| 4 | 22.22 | 11.11 | 11.11 | 44.44 | 50.00 | 25.00 | 25.00 | | 50.00 | 33.33 | 50.00 | ---------+--------+--------+--------+ SOUTH | 2 | 2| 1| 5 | 22.22 | 22.22 | 11.11 | 55.56 | 40.00 | 40.00 | 20.00 | | 50.00 | 66.67 | 50.00 | ---------+--------+--------+--------+ Total 4 3 2 9 44.44 33.33 22.22 100.00 Which TABLES statement was used to completed the following program that produced the output? proc freq data=sales; <_insert_code_> run; A. tables region product; B. tables region,product C. tables region/product; D. tables region*product; 答案:D 本题知识点:PROC FREQ 过程 参考第 47 题。 Q 57 Given the SAS data set WORK.ONE: N BeginDate - --------1 09JAN2010 2 12JAN2010 The following SAS program is submitted: data WORK.TWO; set WORK.ONE; Day=<_insert_code_>; format BeginDate date9.; run; The data set WORK.TWO is created, where Day would be 1 for Sunday, 2 for Monday, 3 for Tuesday, ... : WORK.TWO N BeginDate Day - --------- --1 09JAN2010 1 2 12JAN2010 4 Which expression successfully completed the program and creates the variable Day? A. day(BeginDate) B. weekday(BeginDate)

35

C. dayofweek(BeginDate) D. getday(BeginDate,today()) 答案:B 本题知识点:日期时间函数 WEEKDAY(date)返回 SAS 日期值为一周的第几天 Q 58 The following program is submitted: proc format; value salfmt. 0 -< 50000 = 'Less than 50K' 50000 - high = '50K or Greater'; options fmterr nodate pageno=1; title 'Employee Report'; proc print data=work.employees noobs; var fullname salary hiredate; format salary salfmt. hiredate date9.; label fullname='Name of Employee' salary='Annual Salary' hiredate='Date of Hire'; run; Why does the program fail? A. The PAGENO option is invalid in the OPTIONS statement. B. The RUN statement is missing after the FORMAT procedure. C. The format name contains a period in the VALUE statement. D. The LABEL option is missing from the PROC PRINT statement. 答案:C 本题知识点:FORMAT 语句、PROC FORMAT 过程 参考第 9 题。 Q 59 Given the contents of the raw data file TYPECOLOR.DAT: ----+----10---+----20---+----30 daisyyellow The following SAS program is submitted: data FLOWERS; infile 'TYPECOLOR.DAT' truncover; length Type $ 5 Color $ 11; input Type $ Color $; run; What are the values of the variables Type and Color? A. Type=daisy, Color=yellow B. Type=daisy, Color=w C. Type=daisy, Color=daisyyellow D. Type=daisy, Color= 答案:D

36

本题知识点:INFILE 语句 参考第 5 题。 Q 60 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.REVENUE(drop=Sales Returns Price); set WORK.PRODUCTS(keep=ProdId Price Sales Returns); Revenue=Price*(Sales-Returns); run; How many variables does the WORK.REVENUE data set contain? A. 2 B. 3 C. 4 D. 6 答案:A 本题知识点:DROP=选项,类似 KEEP=及 KEEP 语句 参考第 6 题。 Q 61 Consider the data step: data WORK.TEST; infile 'c:\class1.csv' dsd; input Name $ Sex $ Age Height Weight; if Age NE 16 and Age NE 15 then Group=1; else Group=2; run; Which statement produces a functionally equivalent result for assigning Group a value? A. if Age not in(15,16) then Group=1; else Group=2; B. if (Age NE 16) or (Age NE 15) then Group=1; else Group=2; C. where Age not between 15 and 16 then Group=1; else Group=2; D. both A or C will work. 答案:A 本题知识点:IF 语句、IN 的使用 参考第 17 题。 Q 62 The following SAS program is submitted: <_insert_ods_code_> proc means data=SASUSER.SHOES; where Product in ('Sandal' , 'Slipper' , 'Boot'); run; <_insert_ods_code_> Which ODS statements, inserted in the two locations above, create a report stored in an html file?

37

A. ods html open='sales.html'; ods html close; B. ods file='sales.html' / html; ods file close; C. ods html file='sales.html'; ods html close; D. ods file html='sales.html'; ods file close; 答案:C 本题知识点:PROC COTENTS 过程 ODS 的主要输出目标:LISTING、RESULTS、OUTPUT、HTML、CSVALL、RTF、PDF、其他。 ODS HTML 适用于数据较少的数据集、或汇总的数据集,如 TABULATE 过程。 Q 63 The following SAS program is submitted: data WORK.OUTDS; do until(Prod GT 6); Prod + 1; end; run; What is the value of the variable Prod in the output data set? A. . (missing) B. 6 C. 7 D. Undetermined, infinite loop. 答案:C 本题知识点:WHERE 语句 参考第 40 题。 Q 64 The following SAS program is submitted: data work.accounting; length jobcode $ 12; set work.department; run; The WORK.DEPARTMENT SAS data set contains a character variable named JOBCODE with a length of 5. Which of the following is the length of the variable JOBCODE in the output data set? A. 5 B. 8 C. 12 D. The length can not be determined as the program fails to execute due to errors. 答案:C 本题知识点:LENGTH 语句 LEGTH 规定的是变量的字节长度,不是格式,不能含小数点。 LENGTH variable-specification(s) <DEFAULT=n> 其中,DEFAULT=n 是规定新建的数值变量的默认长度 8 改为 n。 ? 数值变量 对于数值变量,LENGTH 范围为 3-8 字节。LENGTH 可放在任意位置。 在 PROC SQL 中 ALERT 不能改变数值变量长度。 ? 字符变量 对于字符变量,LENGTH 范围为 1-32767 字节,空格占一个字符。LENGTH 必须放在 SET 语句之前。

38

实际上,较少使用 LENGTH 语句,而是通过 PROC SQL 中 ALERT 改变字符变量长度。 Q 65 The following SAS program is submitted: data WORK.ACCOUNTING; set WORK.DEPARTMENT; label Jobcode='Job Description'; run; Which statement is true about the output dataset? A. The label of the variable Jobcode is Job (only the first word). B. The label of the variable Jobcode is Job Desc (only the first 8 characters). C. The label of the variable Jobcode is Job Description. D. The program fails to execute due to errors. Labels must be defined in a PROC step. 答案:C 本题知识点:LABEl 标签语句 参考第 37 题。 Q 66 The following SAS program is submitted: data WORK.SALES; do Year=1 to 5; do Month=1 to 12; X + 1; end; end; run; How many observations are written to the WORK.SALES data set? A. 0 B. 1 C. 5 D. 60 答案:B 本题知识点:默认的 OUTPUT 语句 参考第 40 题。 Q 67 Consider the following data step: data WORK.NEW; set WORK.OLD(keep=X); if X < 10 then X=1; else if X >= 10 AND X LT 20 then X=2; else X=3; run; In filtering the values of the variable X in data set WORK.OLD, what value new value would be assigned to X if its original value was a missing value? A. X would get a value of 1. B. X would get a value of 3. C. X would retain its original value of missing. D. This step does not run because of syntax errors. 答案:A 本题知识点:缺失值的计算

39

逻辑计算时按 ASCII 进行比较, 缺失值主要是空格(ASCII 值为 32) 和英文句号(ASCII 值为 46)。 0-9 为 48-57 A-Z 为 65-90 a-z 为 97-122 Q 68 The following SAS program is submitted: data WORK.ACCOUNTING; set WORK.DEPARTMENT; length EmpId $6; CharEmpid=EmpId; run; If data set WORK.DEPARTMENT has a numeric variable EmpId, which statement is true about the output dataset? A. The type of the variable CharEmpid is numeric. B. The type of the variable CharEmpid is unknown. C. The type of the variable CharEmpid is character. D. The program fails to execute due to errors. 答案:D 本题知识点:数据类型的转换、LENTH 定义长度 参考第 10 题。 Q 69 Given the data set WORK.EMPDATA: Employee_ Manager_ ID Job_Title Department ID ------- ---------------------- ---------------- -----120101 Director Sales Management 120261 120102 Sales Manager Sales Management 120101 120103 Sales Manager II Sales Management 120101 120104 Administration Manager Administration 120101 120105 Secretary I Administration 120101 Which one of the following where statements would display observations with job titles containing the word 'Manager'? A. where substr(Job_Title,(length(Job_Title)-6))='Manager'; B. where upcase(scan(Job_Title,-1,' '))='MANAGER'; C. where Job_Title='% Manager '; D. where Job_Title like '%Manager%'; 答案:D 本题知识点:WHERE 语句 WHERE 语句与数据集中 WHERE 选项是在观察读入 PDV 之前必须满足的一个条件。 WHERE where-expression-1 <logical-operator where-expression-n> 运算符 between and 说明 选择一定数据范围的观测 选择变量值为缺失值的观测 选择包含规定字符的观察 匹配选择观测

is missing/null contain/? like

40

same

and

增加多个从句

LIKE:下划线表示与一个字符匹配,百分号表示任意的多个字符。 Q 70 After a SAS program is submitted, the following is written to the SAS log: 105 data WORK.JANUARY; 106 set WORK.ALLYEAR(keep=Product Month Quantity Cost); 107 if Month='JAN' then output WORK.JANUARY; 108 Sales=Cost * Quantity; 109 drop=Month Quantity Cost; ----22 ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, , <=, <>, =, >, >=, AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=, |, ||, ~=. 110 run; What data set option could be attached to WORK.JANUARY to replace the DROP statement that generated the error in the log? A. (drop Month Quantity Cost) B. (drop Month, Quantity, Cost) C. (drop=Month, Quantity, Cost) D. (drop=Month Quantity Cost) 答案:D 本题知识点:DROP 选项 参考 6 题。与 KEEP=选项类似。

41


相关文章:
SAS-Base认证考试(70真题+答案详解).doc
SAS-Base认证考试(70真题+答案详解)_IT认证_资格考试/认证_教育专
SAS Base认证考试(70真题+答案详解).doc
SAS Base认证考试(70真题+答案详解)_互联网_IT/计算机_专业资料。SAS Base 认证考试70 题 SAS 分多个认证种类:base,advanced,clinic 等,但大多需要先通过 ...
SAS_Base认证考试(70真题+答案详解).pdf
SAS_Base认证考试(70真题+答案详解)_经济学_高等教育_教育专区。SAS Base 认证考试70 题 SAS 分多个认证种类:base,advanced,clinic 等,但大多需要先通过 ...
SAS-base-考试必备-70真题(附答案).doc
SAS-base-考试必备-70真题(答案)_经济学_高等教育_教育专区。sa
SASbase70答案详解.doc
SASbase70答案详解_IT认证_资格考试/认证_教育专区 暂无评价|0人阅读|0次下载|举报文档SASbase70答案详解_IT认证_资格考试/认证_教育专区。答案、中文讲解、原题...
SAS Base认证考试70题(01-10).doc
SAS Base认证考试70题(01-10)_IT认证_资格考试/认证_教育专区。SAS Base 基础程序员认证考试 SAS Base 认证考试70 题(01-10) SAS 分多个认证种类:base...
SAS Base认证考试70题(51-60).doc
SAS Base认证考试70题(51-60)_从业资格考试_资格考试/认证_教育专区。SAS ...答案:D 本题知识点:PROC COTENTS 过程 参考第 22 题。 Q 52 Given the ...
SAS Base认证考试70题(61-70).doc
SAS Base认证考试70题(61-70)_IT认证_资格考试/认证_教育专区。SAS Base ...答案:D 本题知识点:数据类型的转换、LENTH 定义长度 参考第 10 题。 Q 69 ...
SAS_base_考试必备_70真题(附答案).doc
SAS_base_考试必备_70真题(答案) - 1.The following SAS program is submitted: data WORK.TOTAL; set WORK.SAL...
SAS Base认证考试70题(31-40).doc
SAS Base认证考试70题(31-40)_从业资格考试_资格考试/认证_教育专区。SAS Base 认证考试70 题(31-40) Q 31 Given the following raw data records in ...
SAS Base认证考试70题(41-50).doc
SAS Base认证考试70题(41-50)_IT认证_资格考试/认证_教育专区。SAS Base 认证考试70 题(41-50) Q 41 Given the raw data record in the file phone....
SAS base 70题(无答案版,适合练习).doc
SAS base 70题(答案版,适合练习)_IT认证_资格考试/认证_教育专区。SAS Base 认证考试70 题 Q1 1. The following SAS program is submitted: data WORK....
SAS Base认证考试70题(11-20).doc
SAS Base 认证考试70 题(11-20) Q 11 Given the existing SAS program: proc format; value agegrp low-12 ='Pre-Teen' 13-high = 'Teen'; run; ...
SAS Base认证考试70题(21-30).doc
SAS Base 认证考试70 题(21-30) Q 21 Given the SAS data set WORK.PRODUCTS: ProdId ---K12S B132S R18KY2 3KL8BY DY65DW DGTY23 Price ---Pr...
sas base70题+新题版本1.doc
sas base70题+新题版本1_IT认证_资格考试/认证_教育专区。sas base 70题加上一些新的题 1.The following SAS program is submitted: data WORK.TOTAL; set ...
RHCE70考试真题解析.doc
RHCE70考试真题解析_IT认证_资格考试/认证_教育专区。RHCSA考试 网络环境 DNS、...or === create database userlist; use userlist; create table user (number...
SAS BASE 123试题+答案详解.pdf
SAS BASE 123试题+答案详解_IT认证_资格考试/认证_教育专区。sas base 123的答案详解版,可以用来复习巩固70题,通过不是问题~~~ ...
SAS base 考试必备 70真题(附答案).doc
SAS base 考试必备 70真题(答案)_IT认证_资格考试/认证_教育专区。考SAS初级程序员的同学可以在冲刺阶段做的真题,是2008年的考题。1...
SAS认证70题.pdf
SAS认证70题 - Exam Name: Exam Type: Exam Code: SAS Base Programming for SAS (r) 9 SAS A00-211 本页已使...
sas base认证考试经验_图文.pdf
SAS认证考试经验分享 TJgwYLY 官方: SAS认证SAS ...《Sas Crackman practice SASbase70答案详解》 《SAS...SAS Base认证考试(70真题... 41页 2下载券 SAS...
更多相关标签: