1、SAS Base认证考试一70题SAS分多个认证种类:base, advanced, clinic等,但人多需要先通过base认证。 但凡这类商业组织提供的考证,基本都是题库型,所以想考过难度并不大。对于只想拿SAS认证的人,如果熟练掌握网上流传甚广的sas真题70题.通过base认证基本就没问题。Q11. The following SAS program is submitted:data WORK.TOTAL;set WORK.SALARY;by Department Gender;讦 First then Payroll=0;Payroll+Wagerate;if Last.;run;
2、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 DepartmentD Department Gender答案:A本题知识点:H动变量在SAS读取数据时,在PDV过程中会产生很多自动变量,在输出的数据集中是不可见的。FIRST. VARIABLE:同一个BY变量(组)若
3、新的变量值第次出现时.其first.variable值为LAST. VARI ABLE:同一个BY变量(组),若新的变量值最后-次出现时,其last.variable值为另外,在BY变量右面有多个变量时,先按第个变量排序,若第个变量的观测存在重复时,才按第二个变量 排序。Q2Given the following raw data records in TEXT:10|20|30John,FEB,13,25,14,27FinalJohn,MAR,26,17,29,11,23, CurrentTina,FEBJ5J8J2,13,FinalTina,MAR,29)4,19,27,20,Curren
4、tThe following output is desired:Obs Name Month Status Weekl Week2 Week3 Week4 Week51 John FEB Final$13$25$14$272John MAR Current$26$17$29$11$233Tina FEB Final$15$18$12$134Tina MAR Current$29$14$19$27$20Which SAS program correctly produces the desired output?A. data WORK.NUMBERS;length Name $ 4 Mont
5、h $ 3 Status $ 7;infile ,TEXT,dsd;input Name $ Month $;if Month=,FEB, then input Weekl Week2 Week3 Week4 Status $;else if Month二MAR then input Weekl Week2 Week3 Week4 Weeks Status $; format Weekl-Week5 dollar6.;run;proc print data=WORK.NUMBERS;run;B. data WORK.NUMBERS;length Name $ 4 Month $ 3 Statu
6、s $ 7;infile TEXT dlm=7 missover;in put Name $ Month $;if Month=lFEB, then input Weekl Week2 Week3 Week4 Status $;else if Month=MAR then input Weekl Week2 Week3 Week4 Week5 Status $; format Weekl-Week5 dollar6.;run;proc print data=WORK.NUMBERS;run;C. data WORK.NUMBERS;length Name $ 4 Month $ 3 Statu
7、s $ 7;infile TEXT dlm=T;in put Name $ Month $ ;讦 Month=,FEB, then input Weekl Week2 Week3 Week4 Status $;else if Month=lMAR, then input Weekl Week2 Week3 Week4 Weeks Status $;format Weekl-Week5 dollar6.;run;proc print data=WORK.NUMBERS;run;D. data WORK.NUMBERS;length Name $ 4 Month $ 3 Status $ 7;in
8、file ,TEXT, dsd ;input Name $ Month $;讦 MonthFEB1 then input Weekl Week2 Week3 Week4 Status $;else if Month=MAR then input Weekl Week2 Week3 Week4 Weeks Status $;format Weekl-Week5 dollar6.;run;proc print data=WORK.NUMBERS;run;答案:c本题知识点:INFILE语句与指示器、IN options;其中,用来定义文件options给出选择项;有以下三种形式:、(文件标志).(
9、文件名)CARDS指明输入的数据,紧跟着CARDS语句下列选择项(options)可以出现在INFILE语句中:、COLUMN二variable或COLaariable定义个变童其值是指针所在的当前列位置。、END二variable定义个变量作为文件结束的标志。 EOF=label是个语句标号,当INFILE语句读到文件末尾时,作为隐含的GOTO语句的目标、LENGHT二variable定义个变量,其值是当前输入数据行的长度。.FIRSTOBS=linenumber要求从指定的行开始读取数据,而不是从文件的第个记录开始。、OBS=n指定从个顺序输入文件中读取数据的最后个行(即第1第n行)。个观
10、察可能占n行。、 DLM二若分隔符不是空格,则使用DLM二指定.DSD忽略引号中数值的分隔符;自动将字符数据中的引号去掉:将两个相邻分隔符视为缺失值处理。.MISSOVER阻止INPUT进入下行读取,未赋值变量视为缺失值 数值型变虽在下而的情况中,VarB是个字符型变量,其它是数字型变量。赋值于个数字型变量,如:VarA=VarB;在算术运算中使用,如:VarA=VarB+O;与个数字型变量进行比较,如:讦VarB=VarA;在函数中,参数妥求数字型变量,如:VarA=sum(VarB,0);2)、数值型变量- 字符型变量在下而的情况中,VarB是个数字型变量,其它是字符型变量。赋值于个字符型
11、变量,如:VarA=VarB;在与要求字符的运算符起使用,如:VarA=|VarB;在函数中,参数要求字符型变量,如:VarA=trim(VarB);Q4The Excel workbook REGIONS.XLS contains the following four worksheets:EASTWESTNORTHSOUTHThe following program is submitted:libname MYXLS regions.xls;Which PROC PRINT step correctly displays the NORTH worksheet?A. proc print
12、 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
13、name and once with a trailing $Un like a typical data source, data in an Excel spreadsheet n eed not be left and top alig ned. For this Excel has n amed ran ges which allow data to be placed any where in side a spreadsheet By default SAS reads and writes data from named ranges on spreadsheets, but w
14、ill also read spreadsheet data directly in the absenee 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 cr
15、eated 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
16、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 lib name engine to distinguish worksheets from named ranges For more information see the Recommended Readings.Q5Which statement spec讦
17、iws that records 1 through 10 are to be read from the raw data ?A. infile customer.txt11-10;B in put customer.txt stop10;C. infile Customer.txt obs=10;D in put customer.txt1 stop=10;答案:C本题知识点:INFILE的选项FIRSTOBS=常数,要求从指定的行开始读取数据,而不是从文件的第个记录开始。OBS二常数,指定从个顺序输入文件中读取数据的最后个行(即第1第n行)。个观测可能占n行。Q6After a SAS
18、program is submitted, the following is written to the SAS log:101data WORK JANUARY;102set WORK.ALLYEAR(keep=product month num_Sold Cost);103讦 MonthJan then output WORKJANUARY;104Sales=Cost * Num_Sold;105keep二Product Sales;22ERROR 22-322: Syntax error, expecting one of the following: !,9 =/ =/=/AND,
19、EQ GE, GT, INE, LT, MAX, MIN, NE, NG, NL,NOTIN, OR,匸 | j |广二.106run;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语句:KE
20、EP variable(s);不能用于过程步。KEEP二选项:data-set-name( KEEP=variable(s)可以用于数据步(如,DATA语句.SET语句)、过程步。其中,variable是具体变量,不能是数组、_N_、_ERROR_等。Q7Which of the following choices is an unacceptable ODSdestination for producing output that can be viewed in Microsoft Excel?A. MSOFFICE2KB. EXCELXPC. CSVALLD. WINXP答案:D本题知识
21、点: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 defi ned by tagsets This in eludes XML (extensible Markup Language),
22、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 document7 that yo u can re re nder for any destination So, if your boss decides he really wants
23、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 rearrang巳 duplicate, or delete tables to further customize your output摘自 The Little SAS Book(Fourth) P152 页Q8The SAS data set n a
24、med WORK.SALARY con tains 10 observati ons for each departme nt, and is curre ntly ordered by Department The following SAS program is submitted:data WORK.TOTAL;set WORK.SALARY(keep二Department MonthlyWageRate);by Department;讦 First.Department=l then Payroll=0;Payroll+(MonthlyWageRate* 12);if Last.Dep
25、artment=l;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.C. The values of the variable Payroll represent the monthly total for each department in the WORK.SALARY data set.D. T
26、he values of the variable Payroll represent a monthly total for all values of WAGE RATE in the WORK.SALARY data set.答案:c本题知识点:类似第1题Q9 data course;input exam;datalines;50.1trun;proc format;value score 1-50 = Tail151-100 = /Pass/;run;proc report data =course nowd; column exam;define exam / display for
27、mat二score.; run;What is the value for exam?A. FailB. PassC. 50.1D No output答案:c本题知识点:PROC FORMAT语句PROC FORMAT;VALUE namerange-lformatted-text-l;rang2=formattedtext2;ran ge-n=/formatted-text-n,;若name为字符串设计格式,则必须在开头加$,长度不超过32字节: name不能以数字结尾,除了下划线外,不能含其他的任何特殊字符。 在range右侧文本可达到32767字节。变量值是字符串妥加引号。-range是
28、多个值,耍用逗号。连续的要用关键字low. high指代变量中最小和最人的非缺失值。用 排除或指代某些范圉。-other是给其他没列在VALUE中的变量分配格式。Q10The following SAS program is submitted:data WORK.RETAIL;Cost=,$20.000,;Discou nt=. 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
29、 SAS logB 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 out
30、put data set is set to zero. No messages are written to the SAS log答案:c本题知识点:标准数据、以及数据类型的自动转换非标准数据含逗号的数值,如:1,00,001:包含美元符号、十六进制、压缩十进制的数据:日期是最普通的非标准数据。标准数据数字0-9英文句号科学计数、E +、-如果字符型变量转换后不能作为标准数值读入,被转换成的字符型变量有格式要求,必须进行显式转换。Q11Given the existing SAS program:proc format;value agegrplow-12 Pre-Teen113-high
31、 = Teenrun;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 : HeightNSex Age Obs Minimum MaximumMeanF Pre-Teen 351.359.855.8Teen656.566.563.0M Pre-Te
32、en 457.364.859.7Teen662.572.066.8A. var Height / nobs min max mean maxdec=l:B. proc means data=SASHELP.CLASS maxdec=l ;C proc means data=SASHELP.CLASS min max mean maxdec=l;D. oulpul nobs min max mean maxdec=l;答案:C本题知识点:PROC MEANS i程PROC MEANS ;语句;RUN;data=:数檢集maxdec=:指定输出结果的小数位数,默认为7位noprint:禁止结果在O
33、TPUT窗口输出alpha:设定可信区间的a水平,默认为0.05MAX. MIN. MEAN. MEDIAN、N、NMISS. RANGE. STDDEV. SUM若不加统计关键词,默认打印的顺序:非缺失值个数(N).均值(MEAN)、标准差(STDDEV).最小值(N1IN、最人值(MAX)。语句若在PROC MEAN过程中没有其他语句,默认输出所有观测值和所有数值变量的统计量。BY:分变量单独分析,数据必须先按变量顺序扌II柠,即PROC SORTCLASS:分变量单独分析,不用扌II疗VAR:指定使用的数值变量Q12The Excel workbook QTR1.XLS contains
34、 thefollowing Ih代e worksheets:JAN *FEBMARWhich statement correctly assigns a library reference to the Excel workbook?A libname qtrdata qtrl.xls;B. libname qtrl.xls sheets=3;C libname jan feb mar *qtr 1.xls;D. libname mydata qtrl.xls* WORK.heets=(jan.feb.mar);答案* A本题知识点:LIBNAME语句格式LIBNAME libref veng
35、ineSAS-data-library7 vengine/host-options;Q13The following SAS program is submitted:data WORKTEST;set WORK.MEASLES(keep=Janpt Febpt Marpt);array Diff3 Difcount 1 -Difcount3;array Patients3 Janpt Febpt Marpt;run;What new variables are created?A.Difcountl, Difcount2 and Difcount3B.DiffLDiff2 and Diff3
36、C.Janpt, Febpt, and MarptD.Patients 1, Patients2 and Patients3答案:A本题知识点:数组与其他编程语言的数组相比不同在于,SAS数组的每个元素都对应个变量名。数值型数组数组说明中的初始值可省略,默认为缺失值。数组说明中变量可省略,变量名默认为数组名+序号。序号从1开始。ARRAY test(3) Math Chinese English (0,0,0);数组元素的个数由变量个数决定。ARRAY test(*) test3-test8;二维数组,数组元素按行排列。ARRAR x(2,2) xll xl2x21 x22;字符型数组字符型数
37、组药指定数组元素的最大长度,其他与数值型数组相同。ARRAY test(2) S 10 mathor father:临时数组若SAS数组每个元素不对应变量名,即为临时数组。这与其他编程语言相同。ARRAY test(3) .TEMPORARY. (000);临时数组只用于中间计算,不保存入数据集。在数据步中,临时数组在数据步隐含循环中能自动保留上步得到的值Q14Which of the following programs correctly invokes the DATA Step Debugger:A. data WORK.TEST debug;set WORK.PILOTS;State
38、=scan(cityState.2J);if State=NE then description=Centrar;run;B. data WORK.TEST debugger;set WORK.PILOTS;State=scan(cityState.2J);if State=NE* then description=Centrar;run;C.data WORK.TEST / debug;set WORK.PILOTS;State=can(cityState2/);if Stnt=NE then description=Centrar;run;D.data WORK.TEST / debugg
39、er;set WORK.PILOTS;State=scan(cityState.2J);if State=NE then description=Centrar;run;答案:C本题知识点:/ debug语法DEBUG过程的调用方法:在DATA步后而增加DEBUG选项。Q15Which 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
40、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_之外的变量。Q16The following SAS program is submitted:data WORK.DATE INFO:X=,04jul2005,d;DayOfMon
41、th=day(x);MonthOfY ear=month(x);Year=year(x);run;What types of variables are DayOfMonth, MonthOfYear. and Year?A. DayOfMonth. Year, and MonthOtYear are character.B.DayOfMonth, Year, and MonthOfY7ear are numeric.C. DayOfMonth and Year are numeric. MonthOfYear is characterD. DayOfMonth. Year, and MonthOfYear are date values.答案:B本题知识点:SAS中日期时间及函数起点:1960年】月1日0时0分0秒。若将日期时间标示为数值型常数,需使用相应格式。格式值带单引号,后跟个D (日期)、T (时间)、DT (日期时间) 日期函数返回值为数值。Q17Given the following da