您好,欢迎访问三七文档
当前位置:首页 > 金融/证券 > 综合/其它 > SAS-Base认证考试(70真题+答案详解)
1SASBase认证考试—70题SAS分多个认证种类:base,advanced,clinic等,但大多需要先通过base认证。但凡这类商业组织提供的考证,基本都是题库型,所以想考过难度并不大。对于只想拿SAS认证的人,如果熟练掌握网上流传甚广的sas真题70题,通过base认证基本就没问题。Q11.ThefollowingSASprogramissubmitted:dataWORK.TOTAL;setWORK.SALARY;byDepartmentGender;ifFirst._insert_code_thenPayroll=0;Payroll+Wagerate;ifLast._insert_code_;run;TheSASdatasetWORK.SALARYiscurrentlyorderedbyGenderwithinDepartment.WhichinsertedcodewillaccumulatesubtotalsforeachGenderwithinDepartment?A.GenderB.DepartmentC.GenderDepartmentD.DepartmentGender答案:A本题知识点:自动变量在SAS读取数据时,在PDV过程中会产生很多自动变量,在输出的数据集中是不可见的。·FIRST.VARIABLE:同一个BY变量(组),若新的变量值第一次出现时,其first.variable值为1。·LAST.VARIABLE:同一个BY变量(组),若新的变量值最后一次出现时,其last.variable值为1。另外,在BY变量右面有多个变量时,先按第一个变量排序,若第一个变量的观测存在重复时,才按第二个变量排序。Q2GiventhefollowingrawdatarecordsinTEXTFILE.TXT:2----|----10---|----20---|----30John,FEB,13,25,14,27,FinalJohn,MAR,26,17,29,11,23,CurrentTina,FEB,15,18,12,13,FinalTina,MAR,29,14,19,27,20,CurrentThefollowingoutputisdesired:ObsNameMonthStatusWeek1Week2Week3Week4Week51JohnFEBFinal$13$25$14$27.2JohnMARCurrent$26$17$29$11$233TinaFEBFinal$15$18$12$13.4TinaMARCurrent$29$14$19$27$20WhichSASprogramcorrectlyproducesthedesiredoutput?A.dataWORK.NUMBERS;lengthName$4Month$3Status$7;infile'TEXTFILE.TXT'dsd;inputName$Month$;ifMonth='FEB'theninputWeek1Week2Week3Week4Status$;elseifMonth='MAR'theninputWeek1Week2Week3Week4Week5Status$;formatWeek1-Week5dollar6.;run;procprintdata=WORK.NUMBERS;run;B.dataWORK.NUMBERS;lengthName$4Month$3Status$7;infile'TEXTFILE.TXT'dlm=','missover;inputName$Month$;ifMonth='FEB'theninputWeek1Week2Week3Week4Status$;elseifMonth='MAR'theninputWeek1Week2Week3Week4Week5Status$;formatWeek1-Week5dollar6.;3run;procprintdata=WORK.NUMBERS;run;C.dataWORK.NUMBERS;lengthName$4Month$3Status$7;infile'TEXTFILE.TXT'dlm=',';inputName$Month$@;ifMonth='FEB'theninputWeek1Week2Week3Week4Status$;elseifMonth='MAR'theninputWeek1Week2Week3Week4Week5Status$;formatWeek1-Week5dollar6.;run;procprintdata=WORK.NUMBERS;run;D.dataWORK.NUMBERS;lengthName$4Month$3Status$7;infile'TEXTFILE.TXT'dsd@;inputName$Month$;ifMonth='FEB'theninputWeek1Week2Week3Week4Status$;elseifMonth='MAR'theninputWeek1Week2Week3Week4Week5Status$;formatWeek1-Week5dollar6.;run;procprintdata=WORK.NUMBERS;run;答案:C本题知识点:INFILE语句与指示器@、@@INFILEfilespecificationoptions;其中,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相似,但在COLUMNINPUT或FORMATTEDINPUT中使用。比较@与@@的区别:·@用于1个数据行用多个input语句读取,停留到下一个INPUT语句。·@@用于1个数据行含有多个观测值读取时,停留到下一个DATA步。Q3ThefollowingSASprogramissubmitted:dataWORK.DATE_INFO;Day=01;Yr=1960;X=mdy(Day,01,Yr);run;WhatisthevalueofthevariableX?A.thenumericvalue0B.thecharactervalue01011960C.amissingvalueduetosyntaxerrorsD.thestepwillnotcompilebecauseofthecharacterargumentinthemdyfunction.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;·与一个数字型变量进行比较,如:ifVarB=VarA;·在函数中,参数要求数字型变量,如:VarA=sum(VarB,0);2)、数值型变量-字符型变量在下面的情况中,VarB是一个数字型变量,其它是字符型变量。·赋值于一个字符型变量,如:VarA=VarB;·在与要求字符的运算符一起使用,如:VarA=''||VarB;·在函数中,参数要求字符型变量,如:VarA=trim(VarB);Q4TheExcelworkbookREGIONS.XLScontainsthefollowingfourworksheets:EASTWESTNORTHSOUTHThefollowingprogramissubmitted:libnameMYXLS'regions.xls';6WhichPROCPRINTstepcorrectlydisplaystheNORTHworksheet?A.procprintdata=MYXLS.NORTH;run;B.procprintdata=MYXLS.NORTH$;run;C.procprintdata=MYXLS.'NORTH'e;run;D.procprintdata=MYXLS.'NORTH$'n;run;答案:D本题知识点:打印Excel的某个工作表的数据WHATISTHAT“$”CHARACTER?LookingatSASExploreritmaybesurprisingthateachdatasetwrittentoExcelappearstwice,oncewiththeexpectednameandoncewithatrailing“$”.Unlikeatypicaldatasource,datainanExcelspreadsheetneednotbeleftandtopaligned.ForthisExcelhasnamedrangeswhichallowdatatobeplacedanywhereinsideaspreadsheet.BydefaultSASreadsandwritesdatafromnamedrangesonspreadsheets,butwillalsoreadspreadsheetdatadirectlyintheabsenceofanamedrange.WhenanewSASdatasetiscreatedinanExcellibrary,SAScreatesbothaspreadsheetandanamedrange.Eachisgiventhesamename,withthespreadsheetdenotedbyatrailing“$”.IntheexampleatrightCLASSisthenamedrangecreatedbytheExcelengineandCLASS$isthespreadsheetcreatedbytheExcelenginetoholdthenamedrange.WithinSAS,thenamedrangeisreferredtoasWrkbk.CLASS,andthespreadsheetisreferencedusingthenameliteralWrkbk.’CLASS$’n.SASnameliteralsarenametokenswrittenasstringswithinquotationmarks,followedbythelettern.Nameliteralsallowtheuseofspe
本文标题:SAS-Base认证考试(70真题+答案详解)
链接地址:https://www.777doc.com/doc-4564581 .html