SASBase认证考试70真题答案详解.docx

上传人:b****6 文档编号:7057314 上传时间:2023-01-16 格式:DOCX 页数:66 大小:43.49KB
下载 相关 举报
SASBase认证考试70真题答案详解.docx_第1页
第1页 / 共66页
SASBase认证考试70真题答案详解.docx_第2页
第2页 / 共66页
SASBase认证考试70真题答案详解.docx_第3页
第3页 / 共66页
SASBase认证考试70真题答案详解.docx_第4页
第4页 / 共66页
SASBase认证考试70真题答案详解.docx_第5页
第5页 / 共66页
点击查看更多>>
下载资源
资源描述

SASBase认证考试70真题答案详解.docx

《SASBase认证考试70真题答案详解.docx》由会员分享,可在线阅读,更多相关《SASBase认证考试70真题答案详解.docx(66页珍藏版)》请在冰豆网上搜索。

SASBase认证考试70真题答案详解.docx

SASBase认证考试70真题答案详解

SASBase认证考试—70题

SAS分多个认证种类:

base,advanced,clinic等,但大多需要先通过base认证。

但凡这类商业组织提供的考证,基本都是题库型,所以想考过难度并不大。

对于只想拿SAS认证的人,如果熟练掌握网上流传甚广的sas真题70题,通过base认证基本就没问题。

Q1

1.ThefollowingSASprogramissubmitted:

dataWORK.TOTAL;

setWORK.SALARY;

byDepartmentGender;

ifFirst.<_insert_code_>thenPayroll=0;

Payroll+Wagerate;

ifLast.<_insert_code_>;

run;

TheSASdatasetWORK.SALARYiscurrentlyorderedbyGenderwithinDepartment.

WhichinsertedcodewillaccumulatesubtotalsforeachGenderwithinDepartment?

A.Gender

B.Department

C.GenderDepartment

D.DepartmentGender

答案:

A

本题知识点:

自动变量

在SAS读取数据时,在PDV过程中会产生很多自动变量,在输出的数据集中是不可见的。

·FIRST.VARIABLE:

同一个BY变量(组),若新的变量值第一次出现时,其first.variable值为1。

·LAST.VARIABLE:

同一个BY变量(组),若新的变量值最后一次出现时,其last.variable值为1。

另外,在BY变量右面有多个变量时,先按第一个变量排序,若第一个变量的观测存在重复时,才按第二个变量排序。

Q2

GiventhefollowingrawdatarecordsinTEXTFILE.TXT:

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

Thefollowingoutputisdesired:

ObsNameMonthStatusWeek1Week2Week3Week4Week5

1JohnFEBFinal$13$25$14$27.

2JohnMARCurrent$26$17$29$11$23

3TinaFEBFinal$15$18$12$13.

4TinaMARCurrent$29$14$19$27$20

WhichSASprogramcorrectlyproducesthedesiredoutput?

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.;

run;

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有以下三种形式:

①、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步。

Q3

ThefollowingSASprogramissubmitted:

dataWORK.DATE_INFO;

Day="01";

Yr=1960;

X=mdy(Day,01,Yr);

run;

WhatisthevalueofthevariableX?

A.thenumericvalue0

B.thecharactervalue"01011960"

C.amissingvalueduetosyntaxerrors

D.thestepwillnotcompilebecauseofthecharacterargumentinthemdyfunction.

答案:

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);

Q4

TheExcelworkbookREGIONS.XLScontainsthefollowingfourworksheets:

EAST

WEST

NORTH

SOUTH

Thefollowingprogramissubmitted:

libnameMYXLS'regions.xls';

WhichPROCPRINTstepcorrectlydisplaystheNORTHworksheet?

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.NameliteralsallowtheuseofspecialcharactersthatarenototherwiseallowedinSASnames,likethe“$”usedbytheExcellibnameenginetodistinguishworksheetsfromnamedranges.FormoreinformationseetheRecommendedReadings.

摘自《De-MystifyingtheSASLIBNAMEEngineinMicrosoftExcel:

APracticalGuide》

Q5

Whichstatementspecifiesthatrecords1through10aretobereadfromtherawdatafilecustomer.txt?

A.infile'customer.txt'1-10;

B.input'customer.txt'stop@10;

C.infile'customer.txt'obs=10;

D.input'customer.txt'stop=10;

答案:

C

本题知识点:

INFILE的选项

FIRSTOBS=常数,要求从指定的行开始读取数据,而不是从文件的第一个记录开始。

OBS=常数,指定从一个顺序输入文件中读取数据的最后一个行(即第1~第n行)。

一个观测可能占n行。

Q6

AfteraSASprogramissubmitted,thefollowingiswrittentotheSASlog:

101dataWORK.JANUARY;

102setWORK.ALLYEAR(keep=productmonthnum_SoldCost);

103ifMonth='Jan'thenoutputWORK.JANUARY;

104Sales=Cost*Num_Sold;

105keep=ProductSales;

-----

22

ERROR22-322:

Syntaxerror,expectingoneofthefollowing:

!

!

!

&,*,**,+,-,

<=,<>,=,>,>=,

AND,EQ,GE,GT,IN,LE,LT,MAX,MIN,NE,NG,NL,

NOTIN,OR,^=,|,||,~=.

106run;

WhatchangesshouldbemadetotheKEEPstatementtocorrecttheerrorsintheLOG?

A.keep=(ProductSales);

B.keepProduct,Sales;

C.keep=Product,Sales;

D.keepProductSales;

答案:

D

本题知识点:

KEEP语句与KEEP=选项

在处理大型数据集时,KEEP=选项的效率较高。

·KEEP语句:

KEEPvariable(s);不能用于过程步。

·KEEP=选项:

data-set-name(KEEP=variable(s))可以用于数据步(如,DATA语句、SET语句)、过程步。

其中,variable(s)是具体变量,不能是数组、_N_、_ERROR_等。

Q7

WhichofthefollowingchoicesisanunacceptableODSdestinationforproducingoutputthatcanbeviewedinMicrosoftExcel?

A.MSOFFICE2K

B.EXCELXP

C.CSVALL

D.WINXP

答案:

D

本题知识点:

ODS输出

Mostofthesedestinationsaredesignedtocreateoutputforviewingonascreenorforprinting.

TheOUTPUTdestinationcreatesSASdatasets.TheMARKUPdestinationisageneralpurpose

toolforcreatingoutputinformatsdefinedbytagsets.ThisincludesXML(eXtensibleMarkup

Language),EXCELXP,LaTeX,CSV(comma-separatedvalues),andmanyotherformatswheredata

canbethoughtofasseparatedbytags.TheDOCUMENTdestination,ontheotherhand,allows

youtocreateareusableoutput“document”thatyoucanrerenderforanydestination.So,ifyour

bossdecideshereallywantsthatreportinPDF,notRTF,youcanreplaytheoutputdocument

withouthavingtoreruntheentireSASprogramthatcreatedthedata.Withanoutputdocument,

youcanalsorearrange,duplicate,ordeletetablestofurthercustomizeyouroutput.

摘自《TheLittleSASBook》(Fourth)P152页

Q8

TheSASdatasetnamedWORK.SALARYcontains10observationsforeachdepartment,andiscurrentlyorderedbyDepartment.

ThefollowingSASprogramissubmitted:

dataWORK.TOTAL;

setWORK.SALARY(keep=DepartmentMonthlyWageRate);

byDepartment;

ifFirst.Department=1thenPayroll=0;

Payroll+(MonthlyWageRate*12);

ifLast.Department=1;

run;

Whichstatementistrue?

A.ThebystatementintheDATAstepcausesasyntaxerror.

B.ThestatementPayroll+(MonthlyWageRate*12);inthedatastepcausesasyntaxerror.

C.ThevaluesofthevariablePayrollrepresentthemonthlytotalforeachdepartmentintheWORK.SALARYdataset.

D.ThevaluesofthevariablePayrollrepresentamonthlytotalforallvaluesofWAGERATEintheWORK.SALARYdataset.

答案:

C

本题知识点:

类似第1题

Q9

datacourse;

inputexam;

datalines;

50.1

;

run;

procformat;

valuescore1–50=‘Fail’

51–100=‘Pass’;

run;

procreportdata=coursenowd;

columnexam;

defineexam/displayformat=score.;

run;

Whatisthevalueforexam?

A.Fail

B.Pass

C.50.1

D.Nooutput

答案:

C

本题知识点:

PROCFORMAT语句

PROCFORMAT;

VALUEname

range-1=’formatted-text-1′;

range-2=’formatted-text-2′;

……

range-n=’formatted-text-n’;

若name为字符串设计格式,则必须在开头加$,长度不超过32字节;

name不能以数字结尾,除了下划线外,不能含其他的任何特殊字符。

在range右侧文本可达到32767字节。

·变量值是字符串要加引号。

·range是多个值,要用逗号。

·连续的要用-。

·关键字low、high指代变量中最小和最大的非缺失值。

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 幼儿教育 > 幼儿读物

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1