(完整word版)SAS-Base认证考试(70真题+答案详解)_第1页
(完整word版)SAS-Base认证考试(70真题+答案详解)_第2页
(完整word版)SAS-Base认证考试(70真题+答案详解)_第3页
(完整word版)SAS-Base认证考试(70真题+答案详解)_第4页
已阅读5页,还剩38页未读 继续免费阅读

付费下载

下载本文档

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

文档简介

1、SAS Base认证考试 70 题SAS分多个认证种类:base, advanced , clinic 等,但大多需要先通过base 认证。但凡这类商业组织提供的考证,基本都是题库型,所以想考过难度并不大。对于只想拿SAS认证的人,如果熟练掌握网上流传甚广的sas 真题 70 题,通过base 认证基本就没问题。Q 11. The following SAS program is submitted: data WORK.TOTAL;set WORK.SALARY; by Department Gender;if First.<_insert_code_> then Payroll

2、=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. GenderB. DepartmentC. Gender Department D. Department Gender答案: A本题知识点:自动变量在 SAS读取

3、数据时,在PDV 过程中会产生很多自动变量,在输出的数据集中是不可见的。·FIRST.VARIABLE:同一个BY变量(组),若新的变量值第一次出现时,其first.variable值为 1。·LAST.VARIABLE:同一个BY 变量(组),若新的变量值最后一次出现时,其last.variable 值为 1。另外,在 BY 变量右面有多个变量时,先按第一个变量排序,若第一个变量的观测存在重复时,才按第二个变量排序。Q 2Given the following raw data records in TEXTFILE.TXT:1-|-10-|-20-|-30John,FE

4、B,13,25,14,27,FinalJohn,MAR,26,17,29,11,23,CurrentTina,FEB,15,18,12,13,FinalTina,MAR,29,14,19,27,20,CurrentThe following output is desired:Obs Name Month StatusWeek1 Week2Week3Week4 Week51JohnFEBFinal$13$25$14$27.2JohnMARCurrent$26$17$29$11$233TinaFEBFinal$15$18$12$13.4TinaMARCurrent$29$14$19$27$20W

5、hich 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 We

6、ek5 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='MA

7、R' then input Week1 Week2 Week3 Week4 Week5 Status $; format Week1-Week5 dollar6.;2run;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

8、 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

9、 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 给出选择项 ;·filespec

10、ification有以下三种形式:3 、 fileref( 文件标志 ) 、 filename文件(名 ) 、 CARDS指明输入的数据,紧跟着CARDS语句·下列选择项(options) 可以出现在INFILE 语句中 : 、 COLUMN=variable 或 COL=variable 定义一个变量, 其值是指针所在的当前列位置。 、 END=variable 定义一个变量, 作为文件结束的标志。 、 EOF=label 是一个语句标号, 当 INFILE 语句读到文件末尾时, 作为隐含的GOTO 语句的目标。 、 LENGHT=variable 定义一个变量, 其值是当前输入数

11、据行的长度。 、 FIRSTOBS=linenumber 要求从指定的行开始读取数据, 而不是从文件的第一个记录开始。 、 OBS=n 指定从一个顺序输入文件中读取数据的最后一个行(即第 1第 n 行 )。一个观察可能占n 行。 、 DLM= 若分隔符不是空格,则使用DLM=指定 、 DSD 忽略引号中数值的分隔符;自动将字符数据中的引号去掉;将两个相邻分隔符视为缺失值处理。 、 MISSOVER阻止 INPUT 进入下一行读取,未赋值变量视为缺失值。 、 TRUNCOVER与 MISSOVER相似,但在COLUMN INPUT 或 FORMATTED INPUT中使用。比较 与 的区别:&#

12、183; 用于 1 个数据行用多个input 语句读取,停留到下一个INPUT 语句。· 用于 1 个数据行含有多个观测值读取时,停留到下一个DATA 步。Q 3The 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 0B. the character value "01011960"C.

13、a missing value due to syntax errorsD. 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(日期时间)。在本题中,日期函数的参数应该是数值,若是字符串,会先尝试字符串是否可以转换为

14、数值,这是自动转换。自动转换是指系统产生一个临时的变量来完成赋值或运算。当自动转换发生时,会在LOG 窗口中给出提示。1)、字符型变量->数值型变量在下面的情况中,VarB 是一个字符型变量,其它是数字型变量。·赋值于一个数字型变量,如:VarA=VarB;·在算术运算中使用,如:VarA=VarB+0;·与一个数字型变量进行比较,如:if VarB>=VarA;·在函数中,参数要求数字型变量,如:VarA=sum(VarB,0);2)、数值型变量->字符型变量在下面的情况中,VarB 是一个数字型变量,其它是字符型变量。·赋

15、值于一个字符型变量,如:VarA=VarB;·在与要求字符的运算符一起使用,如:VarA=''|VarB;·在函数中,参数要求字符型变量,如:VarA=trim(VarB);Q 4The Excel workbook REGIONS.XLS contains the following four worksheets:EASTWESTNORTHSOUTHThe following program is submitted:libname MYXLS 'regions.xls'5Which PROC PRINT step correctly d

16、isplays 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“ $”ARACTER?CHLooking at SAS Explorer it may be surprising that each

17、 dataset written to Excel appears twice, once with theexpected 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 hasnamed ranges which allow data to be placed anywhere inside a spreadsheet. By default SAS rea

18、ds and writes datafrom 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. Eachis given the same name, with thespreadsheet denoted by a trai

19、ling“ $”.In the example at right CLASS is the named range created by the Excel engine and CLASS$ is the spreadsheetcreated 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.S

20、AS name literals are name tokens written as strings within quotation marks, followed by the letter n. Nameliterals allow the use of special characters that are not otherwise allowed in SAS names , like the“Excel libname engine to distinguish worksheets from named ranges. For more information see the

21、 Recommended Readings.摘自 De-Mystifying the SAS LIBNAME Engine in Microsoft Excel: A Practical GuideQ 5Which 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 'cus

22、tomer.txt' obs=10;D. input 'customer.txt' stop=10;答案: C本题知识点:INFILE 的选项FIRSTOBS=常数,要求从指定的行开始读取数据, 而不是从文件的第一个记录开始。OBS=常数,指定从一个顺序输入文件中读取数据的最后一个行(即第 1第 n 行 )。一个观测可能占n 行。6Q 6After a SAS program is submitted, the following is written to the SAS log:101 data WORK.JANUARY;102 set WORK.ALLYEAR(k

23、eep=product month num_Sold Cost);103 if Month='Jan' then output WORK.JANUARY;104 Sales=Cost * Num_Sold;105 keep=Product Sales;-22ERROR 22-322: Syntax error, expecting one of the following: !,!, &, *, *, +, -, <=, <>, =, >, >=,AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG,

24、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); 不能用于过程步。

25、83;KEEP=选项: data-set-name( KEEP=variable(s) )可以用于数据步(如,DATA 语句、 SET语句)、过程步。其中, variable(s) 是具体变量,不能是数组、_N_、 _ERROR 等。Q 77Which of the following choices is an unacceptable ODS destination for producing output that can be viewed in Microsoft Excel?A. MSOFFICE2KB. EXCELXPC. CSVALLD. WINXP答案: D本题知识点:ODS

26、 输出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), EXCEL

27、XP, 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, allowsyou to create a reusable output “ document ” that yo u can rerender for any destination. So, if your boss decides he really wants tha

28、t report in PDF, not RTF, you can replay the output documentwithout 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 8The SAS data set nam

29、ed 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.Departme

30、nt=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.8C. The values of the variable Payroll represent the monthly total for each department in the WORK.SALARY data set.D. The

31、values of the variable Payroll represent a monthly total for all values of WAGERATE in the WORK.SALARY data set.答案: C本题知识点:类似第1 题Q 9data course;input exam;datalines;50.1;run;proc format;value score 1 50 = Fail51 100 = Pass ;run;proc report data =course nowd;column exam;define exam / display format=s

32、core.;run;What is the value for exam?A. FailB. PassC. 50.1D. No output答案: C本题知识点:PROC FORMAT语句PROC FORMAT;VALUE namerange- 1= formatted-text- 1;range- 2= formatted-text- 2;range- n= formatted-text- n;9若 name 为字符串设计格式,则必须在开头加$,长度不超过32 字节;name 不能以数字结尾,除了下划线外,不能含其他的任何特殊字符。在 range 右侧文本可达到 32767 字节。·

33、;变量值是字符串要加引号。·range 是多个值,要用逗号。·连续的要用 -。·关键字 low 、 high 指代变量中最小和最大的非缺失值。·用 <排除或指代某些范围。·other 是给其他没列在VALUE中的变量分配格式。Q 10The 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 Discoun

34、t 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 l

35、og 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·+、 -如果字符型变量转换

36、后不能作为标准数值读入,被转换成的字符型变量有格式要求,必须进行显式转换。Q 11Given the existing SAS program:proc format;value agegrplow-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

37、generate the following results:Analysis Variable : HeightNSex AgeObsMinimumMaximumMean-FPre-Teen351.359.855.8Teen656.566.563.0MPre-Teen457.364.859.7Teen662.572.066.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 ma

38、xdec=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

39、、 STDDEV 、 SUM11若不加统计关键词,默认打印的顺序:非缺失值个数(N )、均值( MEAN )、标准差(STDDEV )、最小值(MIN )、最大值(MAX )。? 语句若在 PROC MEAN过程中没有其他语句,默认输出所有观测值和所有数值变量的统计量。BY :分变量单独分析,数据必须先按变量顺序排序,即PROC SORTCLASS :分变量单独分析,不用排序VAR :指定使用的数值变量Q 12The Excel workbook QTR1.XLS contains thefollowing three worksheets:JANFEBMARWhich statement c

40、orrectly 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-li

41、brary<options ><engine/host-options>Q 13The following SAS program is submitted:data WORK.TEST;set WORK.MEASLES(keep=Janpt Febpt Marpt);array Diff3 Difcount1-Difcount3;array Patients3 Janpt Febpt Marpt;run;What new variables are created?A. Difcount1, Difcount2 and Difcount3B. Diff1, Diff2

42、 and Diff3C. Janpt, Febpt, and MarptD. 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 x1

43、2 x21 x22;? 字符型数组12字符型数组药指定数组元素的最大长度,其他与数值型数组相同。ARRAY test(2) $ 10 mathor father;? 临时数组若 SAS 数组每个元素不对应变量名,即为临时数组。这与其他编程语言相同。ARRAY test(3) _TEMPORARY_ (0,0,0);临时数组只用于中间计算,不保存入数据集。在数据步中,临时数组在数据步隐含循环中能自动保留上一步得到的值。Q 14Which of the following programs correctly invokes the DATA Step Debugger:A. data WORK.

44、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.PIL

45、OTS;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 15W

46、hich 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 过程中,产生很多自动变量,可以在数据步的表达式中

47、使用,在输出数据集中不可见。在 PDV 过程中, _N_ 、 _ERROR_ 默认为 DROP 。在 KEEP 语句或 KEEP= 选项中,可以使用除了_N_ 、 _ERROR_ 之外的变量。Q 16The following SAS program is submitted:data WORK.DATE_INFO;X='04jul2005'd;13DayOfMonth=day(x);MonthOfYear=month(x);Year=year(x);run;What types of variables are DayOfMonth, MonthOfYear, and Yea

48、r?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(日期

49、)、T (时间)、 DT (日期时间)。日期函数返回值为数值。Q 17Given the following data step:data WORK.GEO;infile datalines;input City $20.;if City='Tulsa' thenState='OK'Region='Central'if City='Los Angeles' thenState='CA'Region='Western'datalines;TulsaLos AngelesBangor;run;After

50、 data step execution, what will data set WORK.GEO contain?A. CityStateRegion-TulsaOKWesternLos AngelesCAWesternBangorWesternB. CityStateRegion-TulsaOKWesternLos AngelesCAWesternBangorC. CityStateRegion-TulsaOKCentralLos AngelesCAWesternBangorWesternD. CityStateRegion-TulsaOKCentralLosCAWesternBangor

51、14答案: A本题知识点:IF语句若执行语句不能在一个语句完成,则使用复合语句DO 和 ENDIF 条件 THEN 语句 ;没有 ENDIF ,没有IF-ELSEIF-ELSE多分支结构 ,语句 1 只能是一个语句。IF 条件 THEN 语句 1;<ELSE 语句 2>;Q 18Which 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 da

温馨提示

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

评论

0/150

提交评论