SASBase認(rèn)證考試70真題答案詳解_第1頁
SASBase認(rèn)證考試70真題答案詳解_第2頁
SASBase認(rèn)證考試70真題答案詳解_第3頁
SASBase認(rèn)證考試70真題答案詳解_第4頁
SASBase認(rèn)證考試70真題答案詳解_第5頁
已閱讀5頁,還剩36頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、SAS Base認(rèn)證考試70題SAS分多個認(rèn)證種類:base,advanced,clinic等,但大多需要先通過base認(rèn)證。但凡這類商業(yè)組織提供的考證,基本都是題庫型,所以想考過難度并不大。對于只想拿SAS認(rèn)證的人,如果熟練掌握網(wǎng)上流傳甚廣的sas真題70題,通過base認(rèn)證基本就沒問題。Q 11. The following SAS program is submitted:data WORK.TOTAL; set WORK.SALARY; by Department Gender; if First. then Payroll=0; Payroll+Wagerate; if Last.;

2、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 DepartmentD. Department Gender答案:A 本題知識點:自動變量在SAS讀取數(shù)據(jù)時,在PDV過程中會產(chǎn)生很多自動變量,在輸出的數(shù)據(jù)集中是不可見的。 FIRST.VARIABLE:同一個B

3、Y變量(組),若新的變量值第一次出現(xiàn)時,其first.variable值為1。 LAST.VARIABLE:同一個BY變量(組),若新的變量值最后一次出現(xiàn)時,其last.variable值為1。另外,在BY變量右面有多個變量時,先按第一個變量排序,若第一個變量的觀測存在重復(fù)時,才按第二個變量排序。 Q 2Given the following raw data records in TEXTFILE.TXT: -|-10-|-20-|-30 John,FEB,13,25,14,27,Final John,MAR,26,17,29,11,23,Current Tina,FEB,15,18,12,

4、13,Final Tina,MAR,29,14,19,27,20,CurrentThe 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 $20Which SAS program correctly

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

6、 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 dollar

7、6.; 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 d

8、ollar6.; 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-Week

9、5 dollar6.; run; proc print data=WORK.NUMBERS; run;答案:C本題知識點:INFILE語句與指示器、INFILE filespecification options;其中,filespecification用來定義文件, options給出選擇項; filespecification有以下三種形式:、fileref(文件標(biāo)志)、filename(文件名)、CARDS指明輸入的數(shù)據(jù),緊跟著CARDS語句 下列選擇項(options)可以出現(xiàn)在INFILE語句中:、COLUMN=variable或COL=variable 定義一個變量, 其值是指針?biāo)?/p>

10、在的當(dāng)前列位置。、END=variable 定義一個變量, 作為文件結(jié)束的標(biāo)志。、EOF=label是一個語句標(biāo)號, 當(dāng)INFILE語句讀到文件末尾時, 作為隱含的GOTO語句的目標(biāo)。、LENGHT=variable 定義一個變量, 其值是當(dāng)前輸入數(shù)據(jù)行的長度。、FIRSTOBS=linenumber 要求從指定的行開始讀取數(shù)據(jù), 而不是從文件的第一個記錄開始。、OBS=n 指定從一個順序輸入文件中讀取數(shù)據(jù)的最后一個行(即第1第n行)。一個觀察可能占n行。、DLM= 若分隔符不是空格,則使用DLM=指定、DSD 忽略引號中數(shù)值的分隔符;自動將字符數(shù)據(jù)中的引號去掉;將兩個相鄰分隔符視為缺失值處理

11、。、MISSOVER 阻止INPUT進(jìn)入下一行讀取,未賦值變量視為缺失值。、TRUNCOVER 與MISSOVER相似,但在COLUMN INPUT或FORMATTED INPUT中使用。 比較 與 的區(qū)別: 用于1個數(shù)據(jù)行用多個input語句讀取,停留到下一個INPUT語句。 用于1個數(shù)據(jù)行含有多個觀測值讀取時,停留到下一個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

12、variable X?A. the numeric value 0B. the character value C. a missing value due to syntax errorsD. the step will not compile because of the character argument in the mdy function.答案:A 本題知識點:數(shù)據(jù)類型的自動轉(zhuǎn)換在SAS中,日期時間是以1960年1月1日0時0分0秒作為起點的。因此,mdy(1,1,1960)=0。若把日期時間表示為常數(shù)時,要使用相應(yīng)的格式,帶單或雙引號,在后面緊跟一個D(日期)、T(時間)、DT

13、(日期時間)。在本題中,日期函數(shù)的參數(shù)應(yīng)該是數(shù)值,若是字符串,會先嘗試字符串是否可以轉(zhuǎn)換為數(shù)值,這是自動轉(zhuǎn)換。自動轉(zhuǎn)換是指系統(tǒng)產(chǎn)生一個臨時的變量來完成賦值或運算。當(dāng)自動轉(zhuǎn)換發(fā)生時,會在LOG窗口中給出提示。1)、字符型變量 - 數(shù)值型變量在下面的情況中,VarB是一個字符型變量,其它是數(shù)字型變量。 賦值于一個數(shù)字型變量,如:VarA=VarB; 在算術(shù)運算中使用,如:VarA=VarB+0; 與一個數(shù)字型變量進(jìn)行比較,如:if VarB=VarA; 在函數(shù)中,參數(shù)要求數(shù)字型變量,如:VarA=sum(VarB,0);2)、數(shù)值型變量 - 字符型變量在下面的情況中,VarB是一個數(shù)字型變量,其它

14、是字符型變量。 賦值于一個字符型變量,如:VarA=VarB; 在與要求字符的運算符一起使用,如:VarA=|VarB; 在函數(shù)中,參數(shù)要求字符型變量,如:VarA=trim(VarB); Q 4The Excel workbook REGIONS.XLS contains the following four worksheets: EAST WEST NORTH SOUTHThe following program is submitted: libname MYXLS regions.xls;Which PROC PRINT step correctly displays the NOR

15、TH 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的某個工作表的數(shù)據(jù)WHAT IS THAT “$” CHARACTER? Looking at SAS Explorer it may be surprising that each dataset written to Excel appears t

16、wice, 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 ra

17、nges 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 r

18、ight 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 t

19、okens 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 Recommend

20、ed Readings.摘自De-Mystifying the SAS LIBNAME Engine in Microsoft Excel: A Practical Guide Q 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 customer.txt obs=10;D. input customer.

21、txt stop=10; 答案:C本題知識點:INFILE的選項FIRSTOBS=常數(shù),要求從指定的行開始讀取數(shù)據(jù), 而不是從文件的第一個記錄開始。OBS=常數(shù),指定從一個順序輸入文件中讀取數(shù)據(jù)的最后一個行(即第1第n行)。一個觀測可能占n行。 Q 6After 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 the

22、n 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 sta

23、tement 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=選項在處理大型數(shù)據(jù)集時,KEEP=選項的效率較高。 KEEP語句:KEEP variable(s); 不能用于過程步。 KEEP=選項:data-set-name( KEEP=variable(s) ) 可以用于數(shù)據(jù)步(如,DATA語句、SET語句)、過程步。其中,variable(s)是具

24、體變量,不能是數(shù)組、_N_、_ERROR_等。 Q 7Which of the following choices is an unacceptable ODSdestination for producing output that can be viewed in Microsoft Excel?A. MSOFFICE2KB. EXCELXPC. CSVALLD. WINXP答案:D本題知識點:ODS輸出Most of these destinations are designed to create output for viewing on a screen or for printi

25、ng.The OUTPUT destination creates SAS data sets. The MARKUP destination is a general purposetool for creating output in formats defined by tagsets. This includes XML (eXtensible MarkupLanguage), EXCELXP, LaTeX, CSV (comma-separated values), and many other formats where datacan be thought of as separ

26、ated 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 yourboss decides he really wants that report in PDF, not RTF, you can replay the output documentwithout having to rerun the entire SAS progr

27、am 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 named WORK.SALARY contains 10 observations for each department, and is currently ordered by Department.The fo

28、llowing 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

29、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. The values of the variable Payroll represent a monthly total for all values of WAGERATE in the WORK.SALA

30、RY data set.答案:C本題知識點:類似第1題 Q 9data 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. FailB. PassC. 50.1D. No output答案:C本題知識點:PROC FORMAT語句PROC FOR

31、MAT;VALUE namerange-1=formatted-text-1;range-2=formatted-text-2;range-n=formatted-text-n;若name為字符串設(shè)計格式,則必須在開頭加$,長度不超過32字節(jié);name不能以數(shù)字結(jié)尾,除了下劃線外,不能含其他的任何特殊字符。在range右側(cè)文本可達(dá)到32767字節(jié)。 變量值是字符串要加引號。 range是多個值,要用逗號。 連續(xù)的要用-。 關(guān)鍵字low、high指代變量中最小和最大的非缺失值。 用 排除或指代某些范圍。 other是給其他沒列在VALUE中的變量分配格式。 Q 10The following S

32、AS 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

33、 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本題知識點:標(biāo)準(zhǔn)數(shù)據(jù)、以及數(shù)據(jù)類型的自動轉(zhuǎn)換非標(biāo)

34、準(zhǔn)數(shù)據(jù) 含逗號的數(shù)值,如:1,00,001; 包含美元符號、十六進(jìn)制、壓縮十進(jìn)制的數(shù)據(jù); 日期是最普通的非標(biāo)準(zhǔn)數(shù)據(jù)。標(biāo)準(zhǔn)數(shù)據(jù) 數(shù)字0-9 英文句號 科學(xué)計數(shù)、E +、-如果字符型變量轉(zhuǎn)換后不能作為標(biāo)準(zhǔn)數(shù)值讀入,被轉(zhuǎn)換成的字符型變量有格式要求,必須進(jìn)行顯式轉(zhuǎn)換。Q 11Given 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 a

35、gegrp.; run;Which statement in the proc means step needs to be modified or addedto 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

36、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 ;語句;RUN; data=:數(shù)據(jù)集maxdec=:指定輸出結(jié)果的小數(shù)位數(shù),默認(rèn)為7位noprint:禁止結(jié)果在OTPUT窗口輸出alpha:設(shè)定可信區(qū)間的水平,默認(rèn)為0.05 MAX、MIN、MEAN、MEDIAN、N

37、、NMISS、RANGE、STDDEV、SUM若不加統(tǒng)計關(guān)鍵詞,默認(rèn)打印的順序:非缺失值個數(shù)(N)、均值(MEAN)、標(biāo)準(zhǔn)差(STDDEV)、最小值(MIN)、最大值(MAX)。 語句若在PROC MEAN過程中沒有其他語句,默認(rèn)輸出所有觀測值和所有數(shù)值變量的統(tǒng)計量。BY:分變量單獨分析,數(shù)據(jù)必須先按變量順序排序,即PROC SORTCLASS:分變量單獨分析,不用排序VAR:指定使用的數(shù)值變量Q 12The Excel workbook QTR1.XLS contains thefollowing three worksheets: JAN FEB MARWhich statement co

38、rrectly 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 librefSAS-data-library ;Q 13The following SAS program is submitted:data

39、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 and Diff3C. Janpt, Febpt, and MarptD. Patients1, Patients2 and Patients3答案:A本題知識點:數(shù)組與其他編程語言的

40、數(shù)組相比不同在于,SAS數(shù)組的每個元素都對應(yīng)一個變量名。 數(shù)值型數(shù)組數(shù)組說明中的初始值可省略,默認(rèn)為缺失值。數(shù)組說明中變量可省略,變量名默認(rèn)為數(shù)組名+序號。序號從1開始。ARRAY test(3)Math Chinese English (0,0,0);數(shù)組元素的個數(shù)由變量個數(shù)決定。ARRAY test(*) test3-test8;二維數(shù)組,數(shù)組元素按行排列。ARRAR x(2,2) x11 x12 x21 x22; 字符型數(shù)組字符型數(shù)組藥指定數(shù)組元素的最大長度,其他與數(shù)值型數(shù)組相同。ARRAY test(2) $ 10 mathor father; 臨時數(shù)組若SAS數(shù)組每個元素不對應(yīng)變量名

41、,即為臨時數(shù)組。這與其他編程語言相同。ARRAY test(3) _TEMPORARY_ (0,0,0);臨時數(shù)組只用于中間計算,不保存入數(shù)據(jù)集。在數(shù)據(jù)步中,臨時數(shù)組在數(shù)據(jù)步隱含循環(huán)中能自動保留上一步得到的值。Q 14Which 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

42、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=

43、NE then description=Central;run;答案:C本題知識點:/ debug 語法DEBUG過程的調(diào)用方法:在DATA步后面增加DEBUG選項。Q 15Which 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= op

44、tion.D. It is automatically dropped.答案:D本題知識點:自動變量_ERROR_在PDV過程中,產(chǎn)生很多自動變量,可以在數(shù)據(jù)步的表達(dá)式中使用,在輸出數(shù)據(jù)集中不可見。在PDV過程中,_N_、_ERROR_默認(rèn)為DROP。在KEEP語句或KEEP=選項中,可以使用除了_N_、_ERROR_之外的變量。Q 16The following SAS program is submitted:data WORK.DATE_INFO; X=04jul2005d; DayOfMonth=day(x); MonthOfYear=month(x); Year=year(x);ru

45、n;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中日期時間及函數(shù)起

46、點:1960年1月1日0時0分0秒。若將日期時間標(biāo)示為數(shù)值型常數(shù),需使用相應(yīng)格式。格式值帶單引號,后跟一個D(日期)、T(時間)、DT(日期時間)。日期函數(shù)返回值為數(shù)值。Q 17Given 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;TulsaLos AngelesBangor;run

47、;After data step execution, what will data set WORK.GEO contain?A.City State Region - - - Tulsa OK Western Los Angeles CA Western Bangor WesternB.City State Region - - - Tulsa OK Western Los Angeles CA Western BangorC.City State Region - - - Tulsa OK Central Los Angeles CA Western Bangor WesternD.Ci

48、ty State Region - - - Tulsa OK Central Los CA Western Bangor答案:A本題知識點:IF語句若執(zhí)行語句不能在一個語句完成,則使用復(fù)合語句DO和ENDIF 條件 THEN 語句;沒有ENDIF,沒有IF-ELSEIF-ELSE多分支結(jié)構(gòu),語句1只能是一個語句。IF 條件 THEN 語句1;;Q 18Which statement describes a characteristic of the SAS automatic variable _ERROR_?A. The _ERROR_ variable maintains a count

49、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 19The SAS data set WORK.ONE contains a numeric variable named Num and a char

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論