SASBase认证考试70真题答案详解.pdf_第1页
SASBase认证考试70真题答案详解.pdf_第2页
SASBase认证考试70真题答案详解.pdf_第3页
SASBase认证考试70真题答案详解.pdf_第4页
SASBase认证考试70真题答案详解.pdf_第5页
已阅读5页,还剩36页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1 SAS Base 认证考试70 题 SAS 分多个认证种类:base,advanced,clinic 等,但大多需要先通过 base 认证。 但凡这类商业组织提供的考证,基本都是题库型,所以想考过难度并不大。 对于只想拿 SAS 认证的人,如果熟练掌握网上流传甚广的 sas 真题 70 题,通过 base 认证基本就没问题。 Q 1 1. The following SAS program is submitted: data WORK.TOTAL; set WORK.SALARY; by Department Gender; if First. then Payroll=0; Payroll+Wagerate; if Last.; 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 变量右面有多个变量时,先按第一个变量排序,若第一个变量的观测存在重复时,才按第二个 变量排序。 Q 2 Given the following raw data records in TEXTFILE.TXT: 2 -|-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 . 2 John MAR Current $26 $17 $29 $11 $23 3 Tina FEB Final $15 $18 $12 $13 . 4 Tina MAR Current $29 $14 $19 $27 $20 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.; 3 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 有以下三种形式: 4 、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 步。 Q 3 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. 5 答案: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); Q 4 The Excel workbook REGIONS.XLS contains the following four worksheets: EAST WEST NORTH SOUTH The following program is submitted: libname MYXLS regions.xls; 6 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.NORTHe;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 Q 5 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 stop10; C. infile customer.txt obs=10; D. input customer.txt stop=10; 答案:C 本题知识点:INFILE 的选项 FIRSTOBS=常数,要求从指定的行开始读取数据, 而不是从文件的第一个记录开始。 OBS=常数,指定从一个顺序输入文件中读取数据的最后一个行(即第 1第 n 行)。一个观测可能占 n 行。 7 Q 6 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: !, !, 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_等。 Q 7 8 Which of the following choices is an unacceptable ODSdestination 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 页 Q 8 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. 9 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 题 Q 9 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; 10 若 name 为字符串设计格式,则必须在开头加$,长度不超过 32 字节; name 不能以数字结尾,除了下划线外,不能含其他的任何特殊字符。 在 range 右侧文本可达到 32767 字节。 变量值是字符串要加引号。 range 是多个值,要用逗号。 连续的要用-。 关键字 low、high 指代变量中最小和最大的非缺失值。 用 数值型变量 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 29 本题知识点:本题知识点: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 X1-Xn X1Xn 的所有变量 Xa、Xb、Xy X: 所有 X 开头的变量 X、Y、Z、A X-A XA的所有变量 X_NUMERIC_A XA的所有数值型变量 X_CHARACTER_A XA的所有字符型变量 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 30 | 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 ; What will the data set WORK.TEST contain? 31 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=MonthSales12); set WORK.MONTHLYSALES(keep=Year Product Sales); array MonthSales12; do i=1 to 12; MonthSalesi=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 MonthSales12. 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 - - 111 E 32 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 本题知识点:本题知识点:PROC COTENTS 过程过程 33 参考第 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 语句语句 retain 语句是非执行语句。 retain; /*针对所有变量*/ 34 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. Citys value will be assigned one time, States 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; Vari

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论