SAS认证考试(官方练习题集和校正答案)

合集下载

SASBase认证考试—70题(61-70)

SASBase认证考试—70题(61-70)

SASBase认证考试—70题(61-70)SAS Base认证考试—70题(61-70)Q 61Consider the data step:data WORK.TEST;infile 'c:\class1.csv' dsd;input Name Sex Age Height Weight;if Age NE 16 and Age NE 15 then Group=1;else Group=2;run;Which statement produces a functionally equivalent result for assigning Group a value?A. if Age not in(15,16) then Group=1; else Group=2;B. if (Age NE 16) or (Age NE 15) then Group=1; else Group=2;C. where Age not between 15 and 16 then Group=1; else Group=2;D. both A or C will work.答案:A本题知识点:IF语句、IN的使用参考第17题。

Q 62The following SAS program is submitted:<_insert_ods_code_>proc means data=SASUSER.SHOES;where Product in ('Sandal' , 'Slipper' , 'Boot');run;<_insert_ods_code_>Which ODS statements, inserted in the two locations above,create a report stored in an html file?A. ods html open='sales.html';ods html close;B. ods file='sales.html' / html;ods file close;C. ods html file='sales.html';ods html close;D. ods file html='sales.html';ods file close;答案:C本题知识点:PROC COTENTS过程ODS的主要输出目标:LISTING、RESULTS、OUTPUT、HTML、CSVALL、RTF、PDF、其他。

sas练习题(打印版)

sas练习题(打印版)

sas练习题(打印版)### SAS练习题(打印版)#### 一、基础数据操作1. 数据导入- 题目:使用SAS导入一个CSV文件,并列出前5个观测值。

- 答案:使用`PROC IMPORT`过程导入数据,并用`PROC PRINT`展示前5个观测。

2. 数据筛选- 题目:筛选出某列数据大于50的所有观测。

- 答案:使用`WHERE`语句进行筛选。

3. 数据分组- 题目:根据某列数据对数据集进行分组,并计算每组的均值。

- 答案:使用`PROC MEANS`过程和`BY`语句进行分组和计算。

4. 数据排序- 题目:按照某列数据的升序或降序对数据集进行排序。

- 答案:使用`PROC SORT`过程进行排序。

#### 二、描述性统计分析1. 单变量分析- 题目:计算某列数据的均值、中位数、标准差等统计量。

- 答案:使用`PROC UNIVARIATE`过程进行单变量描述性统计分析。

2. 频率分布- 题目:计算某列数据的频数和频率分布。

- 答案:使用`PROC FREQ`过程进行频率分布分析。

3. 相关性分析- 题目:计算两列数据的相关系数。

- 答案:使用`PROC CORR`过程计算相关系数。

#### 三、假设检验1. t检验- 题目:对两组独立样本的均值进行t检验。

- 答案:使用`PROC TTEST`过程进行t检验。

2. 方差分析- 题目:对多个组别数据进行方差分析。

- 答案:使用`PROC ANOVA`过程进行方差分析。

3. 卡方检验- 题目:对分类变量进行卡方检验。

- 答案:使用`PROC FREQ`过程和`CHI2TEST`选项进行卡方检验。

#### 四、回归分析1. 简单线性回归- 题目:使用一个自变量和一个因变量进行简单线性回归分析。

- 答案:使用`PROC REG`过程进行简单线性回归。

2. 多元线性回归- 题目:使用多个自变量和一个因变量进行多元线性回归分析。

- 答案:同样使用`PROC REG`过程,但包括多个自变量。

SAS base 考试必备 70真题(附答案)

SAS base 考试必备 70真题(附答案)

1.The following SAS program is submitted:data WORK.TOTAL;set WORK.SALARY;by Department Gender;if First.<_insert_code_> then Payroll=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 DepartmentD. Department GenderAnswer: A-------------------------------------2.Given the following raw data records in TEXTFILE.TXT:----|----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,CurrentThe following output is desired:Obs Name Month Status Week1 Week2 Week3 Week4 Week51 John FEB Final $13 $25 $14 $27 .2 John MAR Current $26 $17 $29 $11 $233 Tina FEB Final $15 $18 $12 $13 .4 Tina MAR Current $29 $14 $19 $27 $20 Which 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 Week5 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='MAR' then input Week1 Week2 Week3 Week4 Week5 Status $;format Week1-Week5 dollar6.;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 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 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;Answer: C-------------------------------------3.The 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 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;Answer: D-------------------------------------4.The 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. a missing value due to syntax errorsD. the step will not compile because of the character argument in the mdy function.Answer: A-------------------------------------5.Which 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' stop@10;C. infile 'customer.txt' obs=10;D. input 'customer.txt' stop=10;Answer: C-------------------------------------6.After 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' 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,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;Answer: D-------------------------------------7.Which of the following choices is an unacceptable ODS destination for producing output that can be viewed in Microsoft Excel?A. MSOFFICE2KB. EXCELXPC. CSVALLD. WINXPAnswer: D-------------------------------------8.The SAS data set named 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.Department=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.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.SALARY data set.Answer: C-------------------------------------10.The 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 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 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.Answer: C 因为有一个$符号-------------------------------------11.Given 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 generate the following results:Analysis Variable : HeightNSex Age Obs Minimum MaximumMean------------------------------------------------------------------F Pre-Teen 3 51.3 59.8 55.8Teen 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 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;Answer: C-------------------------------------12.The Excel workbook QTR1.XLS contains the following three worksheets:JANFEBMARWhich statement correctly 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);Answer: A-------------------------------------13.The following SAS program is submitted:data WORK.TEST;set WORK.MEASLES(keep=Janpt Febpt Marpt);array Diff{3} Difcount1-Difcount3;array Patients{3} 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 Patients3Answer: A-------------------------------------14.Which 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 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='NE' then description='Central';run;Answer: c-------------------------------------15.Which 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.Answer: D-------------------------------------16.The following SAS program is submitted:data WORK.DATE_INFO;X='04jul2005'd;DayOfMonth=day(x);MonthOfYear=month(x);Year=year(x);run;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.Answer: B-------------------------------------17.Given 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 data step execution, what will data set WORK.GEO contain?A.City State Region----------- ----- -------Tulsa OK WesternLos Angeles CA WesternBangor WesternB.City State Region----------- ----- -------Tulsa OK WesternLos Angeles CA WesternBangorC.City State Region----------- ----- -------Tulsa OK CentralLos Angeles CA WesternBangor WesternD.City State Region----------- ----- -------Tulsa OK CentralLos CA WesternBangorAnswer: A-------------------------------------18.Which 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 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.Answer: C-------------------------------------19.The SAS data set WORK.ONE contains a numeric variable named Num and a character variable named Char:WORK.ONENum Char--- ----1 233 231 77The following SAS program is submitted:proc print data=WORK.ONE;where Num='1';run;What is output?A.Num Char--- ----1 23B.Num Char--- ----1 231 77C.Num Char--- ----1 233 231 77D. No output is generated.Answer: D-------------------------------------20. The data set WORK.REALESTATE has the variable LocalFee with a format of 9. and a variable CountryFee with a format of 7.;The following SAS program is submitted:data WORK.FEE_STRUCTURE;format LocalFee CountryFee percent7.2;set WORK.REALESTAT;LocalFee=LocalFee/100;CountryFee=CountryFee/100;run;What are the formats of the variables LOCALFEE and COUNTRYFEE in the output dataset?A. LocalFee has format of 9. and CountryFee has a format of 7.B. LocalFee has format of 9. and CountryFee has a format of percent7.2C. Both LocalFee and CountryFee have a format of percent7.2D. The data step fails execution; there is no format for LocalFee.Answer: C-------------------------------------21.Given the SAS data set WORK.PRODUCTS:ProdId Price ProductType Sales Returns------ ----- ----------- ----- -------K12S 95.50 OUTDOOR 15 2B132S 2.99 CLOTHING 300 10R18KY2 51.99 EQUIPMENT 25 53KL8BY 6.39 OUTDOOR 125 15DY65DW 5.60 OUTDOOR 45 5DGTY23 34.55 EQUIPMENT 67 2The following SAS program is submitted:data WORK.OUTDOOR WORK.CLOTH WORK.EQUIP;set WORK.PRODUCTS;if Sales GT 30;if ProductType EQ 'OUTDOOR' then output WORK.OUTDOOR;else if ProductType EQ 'CLOTHING' then output WORK.CLOTH;else if ProductType EQ 'EQUIPMENT' then output WORK.EQUIP; run;How many observations does the WORK.OUTDOOR data set contain?A. 1B. 2C. 3D. 6Answer: B-------------------------------------22.Which step displays a listing of all the data sets in the WORK library?A. proc contents lib=WORK run;B. proc contents lib=WORK.all;run;C. proc contents data=WORK._all_; run;D. proc contents data=WORK _ALL_; run;Answer: c-------------------------------------23.Which is a valid LIBNAME statement?A. libname "_SAS_data_library_location_";B. sasdata libname "_SAS_data_library_location_";C. libname sasdata "_SAS_data_library_location_";D. libname sasdata sas "_SAS_data_library_location_";Answer: C-------------------------------------24.Given the following raw data records:----|----10---|----20---|----30Susan*12/29/1970*10Michael**6The following output is desired:Obs employee bdate years1 Susan 4015 102 Michael . 6Which SAS program correctly reads in the raw data?A.data employees;infile 'file specification' dlm='*';input employee $ bdate : mmddyy10. years;run;B.data employees;infile 'file specification' dsd='*';input employee $ bdate mmddyy10. years;run;C.data employees;infile 'file specification' dlm dsd;input employee $ bdate mmddyy10. years;run;D.data employees;infile 'file specification' dlm='*' dsd;input employee $ bdate : mmddyy10. years;run;Answer: D-------------------------------------25.Given the following code:proc print data=SASHELP.CLASS(firstobs=5 obs=15);where Sex='M';run;How many observations will be displayed?A. 11B. 15C. 10 or fewerD. 11 or fewerAnswer: D-------------------------------------26.Which step sorts the observations of a permanent SAS data set by two variables and stores the sorted observations in a temporary SAS data set?A.proc sort out=EMPLOYEES data=EMPSORT;by Lname and Fname;run;B.proc sort data=SASUSER.EMPLOYEES out=EMPSORT;by Lname Fname;run;C.proc sort out=SASUSER.EMPLOYEES data=WORK.EMPSORT;by Lname Fname;run;D.proc sort data=SASUSER.EMPLOYEES out=SASUSER.EMPSORT;by Lname and Fname;run;Answer: B-------------------------------------27.Given the SAS data set WORK.TEMPS:Day Month Temp--- ----- ----1 May 7515 May 7015 June 803 June 762 July 8514 July 89The following program is submitted: proc sort data=WORK.TEMPS;by descending Month Day; run;proc print data=WORK.TEMPS; run;Which output is correct?A.Obs Day Month Temp --- --- ----- ----1 2 July 852 14 July 893 3 June 764 15 June 805 1 May 756 15 May 7B.Obs Day Month Temp --- --- ----- ----1 1 May 752 2 July 853 3 June 764 14 July 895 15 May 706 15 June 80C.Obs Day Month Temp --- --- ----- ----1 1 May 752 15 May 703 3 June 764 15 June 805 2 July 856 14 July 89D.Obs Day Month Temp--- --- ----- ----1 15 May 702 1 May 753 15 June 804 3 June 765 14 July 896 2 July 85Answer: C-------------------------------------28.Given the SAS data set WORK.P2000:Location Pop2000-------- -------Alaska 626931Delaware 783595Vermont 608826Wyoming 493782and the SAS data set WORK.P2008:State Pop2008-------- -------Alaska 686293Delaware 873092Wyoming 532668The following output is desired:Obs State Pop2000 Pop2008 Difference1 Alaska 626931 686293 593622 Delaware 783595 873092 894973 Wyoming 493782 532668 38886 Which SAS program correctly combines the data?A.data compare;merge WORK.P2000(in=_a Location=State)WORK.P2008(in=_b);by State;if _a and _b;Difference=Pop2008-Pop2000;run;B.data compare;merge WORK.P2000(rename=(Location=State))WORK.P2008;by State;if _a and _b;Difference=Pop2008-Pop2000;run;C.data compare;merge WORK.P2000(in=_a rename=(Location=State)) WORK.P2008(in=_b);by State;if _a and _b;Difference=Pop2008-Pop2000;run;D.data compare;merge WORK.P2000(in=_a) (rename=(Location=State)) WORK.P2008(in=_b);by State;if _a and _b;Difference=Pop2008-Pop2000;run;Answer: C-------------------------------------29.The following SAS program is sumbitted:data ;infile 'DATAFILE.TXT';input @1 Company $20. @25 State $2. @;if State=' ' then input @30 Year;else input @30 City Year;input NumEmployees;run;How many raw data records are read during each iteration of the DATA step?A. 1B. 2C. 3D. 4Answer: A-------------------------------------30.You're attempting to read a raw data file and you see the following messages displayed in the SAS Log:NOTE: Invalid data for Salary in line 4 15-23.RULE: ----+----1----+----2----+----3----+----4----+----5--4 120104 F 46#30 11MAY1954 33Employee_Id=120104 employee_gender=F Salary=. birth_date=-2061 _ERROR_=1 _N_=4NOTE: 20 records were read from the infile 'c:\employees.dat'.The minimum record length was 33.The maximum record length was 33.NOTE: The data set WORK.EMPLOYEES has 20 observations and 4 variables. What does it mean?A. A compiler error, triggered by an invalid character for the variable Salary.B. An execution error, triggered by an invalid character for the variable Salary.C. The 1st of potentially many errors, this one occurring on the 4th observation.D. An error on the INPUT statement specification for reading the variable Salary.Answer: B------------------------------------------------------------------31. Given the following raw data records in DATAFILE.TXT:----|----10---|----20---|----30Kim,Basketball,Golf,TennisBill,FootballTracy,Soccer,TrackThe following program is submitted:data WORK.SPORTS_INFO;length Fname Sport1-Sport3 $ 10;infile 'DATAFILE.TXT' dlm=',';input Fname $ Sport1 $ Sport2 $ Sport3 $;run;proc print data=WORK.SPORTS_INFO;run;Which output is correct based on the submitted program?A.Obs Fname Sport1 Sport2 Sport31 Kim Basketball Golf Tennis2 Bill Football3 Tracy Soccer TrackB.Obs Fname Sport1 Sport2 Sport31 Kim Basketball Golf Tennis2 Bill Football Football Football3 Tracy Soccer Track TrackC.Obs Fname Sport1 Sport2 Sport31 Kim Basketball Golf Tennis2 Bill Football Tracy SoccerD.Obs Fname Sport1 Sport2 Sport31 Kim Basketball Golf Tennis2 Bill FootballAnswer: C------------------------------------------------------------------32.Consider the following data step:data WORK.NEW;set WORK.OLD;Count+1;run;The variable Count is created using a sum statement. Which statement regarding this variable is true?A. It is assigned a value 0 when the data step begins execution.B. It is assigned a value of missing when the data step begins execution.C. It is assigned a value 0 at compile time.D. It is assigned a value of missing at compile time.Answer: C------------------------------------------------------------------33.The following SAS program is submitted:data WORK.TEST;set WORK.PILOTS;if Jobcode='Pilot2' then Description='Senior Pilot';else Description='Unknown';run;The value for the variable Jobcode is: PILOT2.What is the value of the variable Description?A. PILOT2B. UnknownC. Senior PilotD. ' ' (missing character value)Answer: B------------------------------------------------------------------34.A user-defined format has been created using the FORMAT procedure.How is it stored?A. in a SAS catalogB. in a memory resident lookup tableC. in a SAS dataset in the WORK libraryD. in a SAS dataset in a permanent SAS data libraryAnswer: AThese formats must be stored in the WORK.FORMATS or SASUSER.FORMATS catalog------------------------------------------------------------------35.given the SAS data set SASDATA.TWO:X Y-- --5 23 15 6The following SAS program is submitted:data SASUSER.ONE SASUSER.TWO OTHER;set SASDATA.TWO;if X eq 5 then output SASUSER.ONE;if Y lt 5 then output SASUSER.TWO;output;run;What is the result?A.data set SASUSER.ONE has 5 observationsdata set SASUSER.TWO has 5 observationsdata set WORK.OTHER has 3 observationsB.data set SASUSER.ONE has 2 observationsdata set SASUSER.TWO has 2 observationsdata set WORK.OTHER has 1 observationsC.data set SASUSER.ONE has 2 observationsdata set SASUSER.TWO has 2 observationsdata set WORK.OTHER has 5 observationsD. No data sets are output. The DATA step fails execution due to syntax errors. Answer: A------------------------------------------------------------------36.Given the contents of the raw data file 'EMPLOYEE.TXT':----+----10---+----20---+----30--Xing 2 19 2004 ACCTBob 5 22 2004 MKTGJorge 3 14 2004 EDUCThe following SAS program is submitted:data WORK.EMPLOYEE;infile 'EMPLOYEE.TXT';input@1 FirstName $@15 StartDate@25 Department $;run;Which SAS informat correctly completes the program?A. date9.B. mmddyy10.C. ddmmyy10.D. mondayyr10.Answer: B-------------------------------------------------------------37.The SAS data set Fed.Banks contains a variable Open_Date which hasbeen assigned a permanent label of "Open Date". Which SAS program temporarily replaces the label "Open Date" with the label "Starting Date" in the output?A.proc print data=SASUSER.HOUSES label;label Open_Date "Starting Date";run;B.proc print data=SASUSER.HOUSES label;label Open_Date="Starting Date";run;C.proc print data=SASUSER.HOUSES;label Open_Date="Starting Date";run;D.proc print data=SASUSER.HOUSES;Open_Date="Starting Date";run;Answer: B------------------------------------------------------------------ 38.Given the SAS data set WORK.ONE:X Y Z- - --1 A 271 A 331 B 452 A 522 B 693 B 704 A 824 C 91The following SAS program is submitted:data WORK.TWO;set WORK.ONE;by X Y;if First.Y;run;proc print data=WORK.TWO noobs;run;Which report is produced?A.X Y Z-- -- --1 B 452 A 522 B 693 B 704 A 824 C 91B.X Y Z-- -- --1 A 271 B 452 A 522 B 693 B 704 A 824 C 91C.X Y Z-- -- --1 A 331 B 452 A 522 B 693 B 704 A 824 C 91D. The PRINT procedure fails because the data set WORK.TWO is not created in the DATA step.Answer: B------------------------------------------------------------------39.The following SAS program is submitted:data WORK.AUTHORS;array Favorites{3} $ 8 ('Shakespeare','Hemingway','McCaffrey');run;What is the value of the second variable in the dataset WORK.AUTHORS?A. HemingwayB. HemingwaC. ' ' (a missing value)D. The program contains errors. No variables are created.Answer: B------------------------------------------------------------------40.The following SAS program is submitted:data WORK.PRODUCTS;Prod=1;do while(Prod LE 6);Prod + 1;end;run;What is the value of the variable Prod in the output data set?A. 6B. 7C. 8D. . (missing numeric)Answer: B------------------------------------------------------------------41.Given the raw data record in the file phone.txt:----|----10---|----20---|----30---|Stevens James SALES 304-923-3721 14The following SAS program is submitted:data WORK.PHONES;infile 'phone.txt';input EmpLName $ EmpFName $ Dept $ Phone $ Extension;<_insert_code_>run;Which SAS statement completes the program and results in a value of "James Stevens" for the variable FullName?A. FullName=CATX(' ',EmpFName,EmpLName);B. FullName=CAT(' ',EmpFName,EmpLName);C. FullName=EmpFName!!EmpLName;D. FullName=EmpFName + EmpLName;Answer: A------------------------------------------------------------------42.The following SAS program is submitted:data WORK.ONE;Text='Australia, US, Denmark';Pos=find(Text,'US','i',5);run;What value will SAS assign to Pos?A. 0B. 1C. 2D. 12Answer: D------------------------------------------------------------------43.Given the SAS data set WORK.ORDERS:WORK.ORDERSorder_id customer shipped-------- ------------ ---------9341 Josh Martin 02FEB20099874 Rachel Lords 14MAR200910233 Takashi Sato 07JUL2009The variable order_id is numeric; customer is character; and shipped is numeric, contains a SAS date value, and is shown with the DATE9. format.A programmer would like to create a new variable, ship_note, that shows a character value with the order_id,shipped date, and customer name.For example, given the first observation ship_note would have the value "Order 9341 shipped on 02FEB2009 to Josh Martin".Which of the following statement will correctly create the value and assign it to ship_note?A. ship_note=catx(' ','Order',order_id,'shippedon',input(shipped,date9.),'to',customer);B. ship_note=catx(' ','Order',order_id,'shippedon',char(shipped,date9.),'to',customer);C. ship_note=catx(' ','Order',order_id,'shippedon',transwrd(shipped,date9.),'to',customer);D. ship_note=catx(' ','Order',order_id,'shippedon',put(shipped,date9.),'to',customer);Answer: D------------------------------------------------------------------44.The following SAS program is submitted:data ONE TWO SASUSER.TWOset SASUSER.ONE;run;Assuming that SASUSER.ONE exists, how many temporary and permanent SAS data sets are created?A. 2 temporary and 1 permanent SAS data sets are createdB. 3 temporary and 2 permanent SAS data sets are createdC. 2 temporary and 2 permanent SAS data sets are createdD. there is an error and no new data sets are createdAnswer: D------------------------------------------------------------------45.The following SAS program is submitted:ods csvall file='c:\test.cvs';proc print data=WORK.ONE;var Name Score Grade;by IdNumber;run;ods csvall close;What is produced as output?A. A file named test.cvs that can only be opened in Excel.B. A text file named test.cvs that can be opened in Excel or in any text editor.C. A text file named test.cvs that can only be opened in a text editor.D. A file named test.cvs that can only be opened by SAS.Answer: C------------------------------------------------------------------46.Given the SAS data set WORK.ONE:Obs Revenue2008 Revenue2009 Revenue2010--- ----------- ----------- -----------1 1.2 1.6 2.0The following SAS program is submitted:。

sas考试题库及答案

sas考试题库及答案

sas考试题库及答案1. 在SAS中,如何使用`proc print`步骤来输出数据集的前几行?A. 使用`proc print data=dataset;`命令B. 使用`proc print data=dataset firstobs=5;`命令C. 使用`proc print data=dataset first=5;`命令D. 使用`proc print data=dataset top;`命令正确答案是B。

2. 如果想要在SAS中创建一个数据集,并将某个变量的值替换为缺失值,应该如何操作?A. 使用`data`步骤和`if`语句B. 使用`data`步骤和`replace`函数C. 使用`proc sql`步骤D. 使用`proc means`步骤正确答案是A。

3. 在SAS中,如何将一个数据集的列名从`Var1`更改为`Variable1`?A. 使用`rename`语句:`rename Var1=Variable1;`B. 使用`rename`语句:`rename Variable1=Var1;`C. 使用`proc contents`步骤D. 使用`proc print`步骤正确答案是A。

4. 如何在SAS中使用`proc means`步骤来计算数据集的描述性统计量?A. 使用`proc means data=dataset;`命令B. 使用`proc means data=dataset N NMISS MEAN MEDIAN MAX MIN;`命令C. 使用`proc means data=dataset out=means;`命令D. 使用`proc means data=dataset out=means N NMISS MEAN MEDIAN MAX MIN;`命令正确答案是D。

5. 在SAS中,如何使用`proc sort`步骤对数据集进行排序?A. 使用`proc sort data=dataset;`命令B. 使用`proc sort data=dataset out=sorted_dataset;`命令C. 使用`proc sort data=dataset by variable;`命令D. 使用`proc sort data=dataset out=sorted_dataset by variable;`命令正确答案是D。

SAS认证考试样题(123题)

SAS认证考试样题(123题)

Exam:A00-201Titl e :SAS Base Programming Ver : 11.30.06QUESTION 1In the following SAS program, the input data files are sorted by the NAMES variable:libnametemp 'SAS-data-library';data temp.sales;merge temp.saleswork.receipt;by names;run;Which one of the following results occurs when this program is submitted?A. The program executes successfully and a temporary SAS data set is created.B. The program executes successfully and a permanent SAS data set is created.C. The program fails execution because the same SAS data set is referenced for both read and write operations.D. The program fails execution because the SAS data sets on the MERGE statement are in two different libraries.Answer: BQUESTION 2When the following SAS program is submitted, the data set SASDATA.PRDSALES contains 5000 observations:libnamesastemp 'SAS-data-library';options obs = 500;proc print data = sasdata.prdsales (firsttobs = 100);run;options obs = max;proc means data = sasdata.prdsales (firsttobs = 500);run;How many observations are processed by each procedure?A. 400 for PROC PRINT4500 for PROC MEANSB. 401 for PROC PRINT4501 for PROC MEANSC. 401 for PROC PRINT4500 for PROC MEANSD. 500 for PROC PRINT5000 for PROC MEANSAnswer: BQUESTION 3The following SAS program is submitted:data work.new;length word $7;amount = 7;if amount = 5 then word = 'CAT';else if amount = 7 then word = 'DOG';else work = 'NONE!!!';amount = 5;run;Which one of the following represents the values of the AMOUNT and WORD variables?A. amount word5 DOGB. amount word5 CATC. amount word7 DOGD. amount word7 ' ' (missing character value)Answer: AQUESTION 4Which one of the following is true of the SUM statement in a SAS DATA step program?A. It is only valid in conjunction with a SUM function.B. It is not valid with the SET, MERGE and UPDATE statements.C. It adds the value of an expression to an accumulator variable and ignores missing values.D. It does not retain the accumulator variable value from one iteration of the SAS DATA step to the next.Answer: CQUESTION 5The following SAS program is submitted:data work.sets;do until (prod gt 6);prod + 1;end;run;Which one of the following is the value of the variable PROD in the output data set?A. 5B. 6C. 7D. 8Answer: CQUESTION 6The following SAS program is submitted:proc print data = sasuser.houses;run;<insert OPTIONS statement here>proc means data = sasuser.shoes;run;Which one of the following OPTIONS statements resets the page number to 1 for the second report?A. option pageno = 1;B. option pagenum = 1;C. options reset pageno = 1;D. options reset pagenum = 1;Answer: AQUESTION 7The contents of the raw data file PRODUCT are listed below:----|----10---|----20---|----3024613 $25.31The following SAS program is submitted:data inventory;infile 'product';input idnum 5. @10 price;run;Which one of the following is the value of the PRICE variable?A. 25.31B. $25.31C. . (missing numeric value)D. No value is stored as the program fails to execute due to errors.Answer: CQUESTION 8The contents of the raw data file TYPECOLOR are listed below:----|----10---|----20---|----30daisyyellowThe following SAS program is submitted:data flowers;infile'typecolor';input type $ 1-5 +1 color $;run;Which one of the following represents the values of the variables TYPE and COLOR?A. type colordaisy yellowB. type colordaisy ellowC. type colordaisyyellow (missing character value)D. No values are stored as the program fails to execute due to syntax errors. Answer: BQUESTION 9A raw data record is listed below:----|----10---|----20---|----30son,Travis,The following output is desired:relation firstnameson TravisWhich one of the following SAS programs reads the data correctly?A. data family / dlm = ',';infile 'file-specification';input relation $ firstname $;run;B. option dlm = ',';data family;infile 'file-specification';input relation $ firstname $;run;C. data family;infile 'file-specification' option dlm = ',';input relation $ firstname $;run;D. data family;infile 'file-specification';input relation $ firstname $ / dlm = ',';run;Answer: CQUESTION 10The following SAS program is submitted:libnamerawdata1 'location of SAS data library';filename rawdata2 'location of raw data file';data work.testdata;infile<insert item here>input sales1 salse2;run;Which one of the following is needed to complete the program correctly?A. rawdata1B. rawdata2C. 'rawdata1'D. 'rawdata2'Answer: BQUESTION 11The following SAS program is submitted and reads 100 records from a raw data file:data work.total;infile 'file-specification' end = eof;input name $ salary;totsal+ salary;<insert IF statement here>run;Which one of the following IF statements writes the last observation to the output data set?A. if end = 0;B. if eof = 0;C. if end = 1;D. if eof = 1;Answer: DQUESTION 12The contents of the raw data file FURNITURE are listed below:----|----10---|----20---|----30chair,,tablechair,couch,tableThe following SAS program is submitted:data stock;infile 'furniture' dsd;input item1 $ item2 $ item3 $;run;Which one of the following is the value of the variable named ITEM2 in the first observation of the output data set?A. tableB. ,tableC. . (missing numeric value)D. ' ' (missing character value)Answer: DQUESTION 13A raw data file is listed below:RANCH,1250,2,1,Sheppard Avenue,"$64,000"SPLIT,1190,1,1,Rand Street,"$65,850"CONDO,1400,2,1.5,Market Street,"80,050"TWOSTORY,1810,4,3,Garris Street,"$107,250"RANCH,1500,3,3,Kemble Avenue,"$86,650"SPLIT,1615,4,3,West Drive,"94,450"SPLIT,1305,3,1.5,Graham Avenue,"$73,650"The following SAS program is submitted using the raw data file as input:data work.condo_ranch;infile'file-specification' dsd;input style $ @;if style = 'CONDO' or style = 'RANCH' theninput sqfeet bedrooms baths street $ price : dollar10.;run;How many observations does the WORK.CONDO_RANCH data set contain?A. 0B. 3C. 5D. 7Answer: DQUESTION 14A raw data file is listed below:RANCH,1250,2,1,Sheppard Avenue,"$64,000"SPLIT,1190,1,1,Rand Street,"$65,850"CONDO,1400,2,1.5,Market Street,"80,050"TWOSTORY,1810,4,3,Garris Street,"$107,250"RANCH,1500,3,3,Kemble Avenue,"$86,650"SPLIT,1615,4,3,West Drive,"94,450"SPLIT,1305,3,1.5,Graham Avenue,"$73,650"The following SAS program is submitted using the raw data file as input:data work.condo_ranch;infile'file-specification' dsd;input style $ @;if style = 'CONDO' or style = 'RANCH';input sqfeet bedrooms baths street $ price : dollar10.;run;How many observations will the output data set contain?A. 0B. 3C. 5D. 7Answer: BQUESTION 15The following SAS program is submitted:data numrecords;infile 'file-specification';input @1 patient $15.relative $ 16-26 @;if relative = 'children' theninput @54 diagnosis $15. @;else if relative = 'parents' theninput @28 doctor $15.clinic $ 44-53@54 diagnosis $15. @;input age;run;How many raw data records are read during each iteration of the DATA step during execution?A. 1B. 2C. 3D. 4Answer: AQUESTION 16The following SAS program is submitted:data work.empsalary;set work.people (in = inemp)work.money(in = insal);if insal and inemp;run;The SAS data set WORK.PEOPLE has 5 observations, and the data setWORK.MONEY has 7 observations.How many observations will the data set WORK.EMPSALARY contain?A. 0B. 5C. 7D. 12Answer: AQUESTION 17The contents of two SAS data sets named EMPLOYEE and SALARY are listed below:EMPLOYEE SALARYname age name salaryBruce 30 Bruce 40000Dan 35 Bruce 35000Dan 37000Dan .The following SAS program is submitted:data work.empsalary;merge work.employee (in = inemp)work.salary(in = insal);by name;if inemp and insal;run;How many observations will the data set WORK.EMPSALARY contain?A. 2B. 4C. 5D. 6Answer: BQUESTION 18The SAS data sets WORK.EMPLOYEE and WORK.SALARY are listed below: WORK.EMPLOYEE WORK.SALARYfnameage fname salaryBruce 30 Bruce 25000Dan 40 Bruce 35000Dan 25000The following SAS program is submitted:data work.empdata;merge work.employeework.salary;by fname;totsal+ salary;run;How many variables are output to the WORK.EMPDATA data set?A. 3B. 4C. 5D. No variables are output to the data set as the program fails to execute due to errors. Answer: BQUESTION 19The SAS data sets WORK.EMPLOYEE and WORK.SALARY are shown below: WORK.EMPLOYEE WORK.SALARYfnameage name salaryBruce 30 Bruce 25000Dan 40 Bruce 35000Dan 25000The following SAS program is submitted:data work.empdata;<insert MERGE statement here>by fname;totsal+ salary;run;Which one of the following statements completes the merge of the two data sets by the FNAME variable?A. merge work.employeework.salary (fname = name);B. merge work.employeework.salary (name = fname);C. merge work.employeework.salary (rename = (fname = name));D. merge work.employeework.salary (rename = (name = fname));Answer: DQUESTION 20The following SAS program is submitted:proc sort data=work.employee;by descending fname;proc sort sort data=work.salary;by descending fname;data work.empdata;merge work.employeework.salary;by fname;run;Which one of the following statements explains why the program failed execution?A. The SORT procedures contain invalid syntax.B. The merged data sets are not permanent SAS data sets.C. The data sets were not merged in the order by which they were sorted.D. The RUN statements were omitted after each of the SORT procedures.Answer: CQUESTION 21The following SAS SORT procedure step generates an output data set:proc sort data = sasuser.houses out = report;by style;run;In which library is the output data set stored?A. WORKB. REPORTC. HOUSESD. SASUSERAnswer: AQUESTION 22The following SAS DATA step is submitted:libnametemp 'SAS-data-library';data temp.report;set sasuser.houses;newvar= price * 1.04;run;Which one of the following statements is true regarding the program above?A. The program is reading from a temporary data set and writing to a temporary data set.B. The program is reading from a temporary data set and writing to a permanent data set.C. The program is reading from a permanent data set and writing to a temporary data set.D. The program is reading from a permanent data set and writing to a permanent data set. Answer: DQUESTION 23Which one of the following SAS DATA steps saves the temporary data set named MYDATA as a permanent data set?A. libname sasdata 'SAS-data-library';data sasdata.mydata;copy mydata;run;B. libname sasdata 'SAS-data-library';data sasdata.mydata;keep mydata;run;C. libname sasdata 'SAS-data-library';data sasdata.mydata;save mydata;run;D. libname sasdata 'SAS-data-library';data sasdata.mydata;set mydata;run;Answer: DQUESTION 24The following SAS DATA step is submitted:data sasdata.atlantasasdata.bostonwork.portlandwork.phoenix;set company.prdsales;if region = 'NE' then output bostan;if region = 'SE' then output atlanta;if region = 'SW' then output phoenix;if region = 'NW' then output portland;run;Which one of the following is true regarding the output data sets?A. No library references are required.B. The data sets listed on all the IF statements require a library reference.C. The data sets listed in the last two IF statements require a library reference.D. The data sets listed in the first two IF statements require a library reference. Answer: DQUESTION 25The following SAS DATA step executes on Monday, April 25, 2000:data newstaff;set staff;start_date=today();run;Which one of the following is the value of the variable START_DATE in the output data set?A. a character string with the value '04/25/2000'B. a character string with the value 'Monday, April 25, 2000'C. the numeric value 14725, representing the SAS date for April 25, 2000D. the numeric value 04252000, representing the SAS date for April 25, 2000 Answer: CQUESTION 26The following SAS program is submitted:data work.new;mon= 3;day = 23;year =2000;date = mdy(mon,day,year);run;Which one of the following is the value of the DATE variable?A. a character string with the value '23mar2000'B. a character string with the value '03/23/2000'C. a numeric value of 14692, which represents the SAS date value for March 23, 2000D. a numeric value of 3232000, which represents the SAS date value for March 23, 2000 Answer: CQUESTION 27The following SAS program is submitted:data revenue;set year_1;var1 = mdy(1,15,1960);run;Which one of the following values does the variable named VAR1 contain?A. 14B. 15C. 1151960D. '1/15/1960'Answer: AQUESTION 28The following SAS program is submitted:data work.report;set work.sales_info;if qtr(sales_date) ge 3;run;The SAS data set WORK.SALES_INFO has one observation for each month in the year 2000 and the variable SALES_DATE which contains a SAS date value for each of the twelve months.How many of the original twelve observations in WORK.SALES_INFO are written to the WORK.REPORT data set?A. 2B. 3C. 6D. 9Answer: CQUESTION 29The following SAS program is submitted:?libnametemp 'SAS-data-library';data work.new;set temp.jobs;format newdate mmddyy10.;qdate= qtr(newdate);ddate= weekday(newdate);run;proc print data = work.new;run;The variable NEWDATE contains the SAS date value for April 15, 2000.What output is produced if April 15, 2000 falls on a Saturday?A. Obs newdate qdate ddate1 APR1520002 6B. Obs newdate qdate ddate1 04/15/20002 6C. Obs newdate qdate ddate1 APR1520002 7D. Obs newdate qdate ddate1 04/15/20002 7Answer: DQUESTION 30A raw data record is shown below:07Jan2002Which one of the following informats would read this value and store it as a SAS date value?A. date9.B. ddmonyy9.C. ddMMMyy9.D. ddmmmyyyy9.Answer: AQUESTION 31The contents of the SAS data set PERM.JAN_SALES are listed below: VARIABLE NAME TYPEidnumcharacter variablesales_datenumeric date valueA comma delimited raw data file needs to be created from the PERM.JAN_SALES data set. The SALES_DATE values need to be in a MMDDYY10 form.Which one of the following SAS DATA steps correctly creates this raw data file?A. libname perm 'SAS-data-library';data_null_;set perm.jan_sales;file 'file-specification' dsd = ',';put idnum sales_date : mmddyy 10.;run;B. libname perm 'SAS-data-library';data_null_;set perm.jan_sales;file 'file-specification' dlm = ',';put idnum sales_date : mmddyy 10.;run;C. libname perm 'SAS-data-library';data_null_;set perm.jan_sales;file 'file-specification';put idnum sales_date : mmddyy 10. dlm = ',';run;D. libname perm 'SAS-data-library';data_null_;set perm.jan_sales;file 'file-specification';put idnum sales_date : mmddyy 10. dsd = ',';run;Answer: BQUESTION 32The contents of the SAS data set named PERM.STUDENTS are listed below:Alfred 14Alice13Barbara 13Carol 14The following SAS program is submitted using the PERM.STUDENTS data set as input:Libnameperm 'SAS-date-library';data students;set perm.students;file 'file-specification';put name $15. @5 age 2.;runWhich one of the following represents the values written to the output raw data file?A. ----|----10---|----20---|----30Alfred 14Alice 13Barbara 13Carol 14B. ----|----10---|----20---|----30Alfr14Alic13Barb13aCaro14C. ----|----10---|----20---|----30Alfr14edAlic13eBarb13araCaro14lD. ----|----10---|----20---|----30Alfred 14Alice 13Barbara 13Carol 14Answer: BQUESTION 33The contents of the raw data file TEAM are listed below:----|----10---|----20---|----30Janice 10Henri 11Michael 11Susan 12The following SAS program is submitted:infile 'team';input name $15. age 2.;file 'file-specification';put name $15. =5 age 2.;run;Which one of the following describes the output created?A. a raw data file onlyB. a SAS data set named GROUP onlyC. a SAS data set named GROUP and a raw data fileD. No output is generated as the program fails to execute due to errors.Answer: CQUESTION 34The following SAS program is submitted:data_null_;set old;put sales1 sales2;run;Where is the output written?A. the SAS logB. the raw data file that was opened lastC. the SAS output window or an output fileD. the data set mentioned in the DATA statementAnswer: AQUESTION 35The following SAS program is submitted:data_null_;set old (keep = prod sales1 sales2);file 'file-specification';put sales1 sales2;run;Which one of the following default delimiters separates the fields in the raw data file created?A. : (colon)B. (space)C. , (comma)D. ;(semicolon)Answer: BQUESTION 36The following SAS program is submitted:data allobs;set sasdata.origin (firstobs = 75 obs = 499);run;The SAS data set SASDATA.ORIGIN contains 1000 observations.How many observations does the ALLOBS data set contain?A. 424B. 425C. 499D. 1000Answer: BQUESTION 37The SAS data set named COMPANY.PRICES is listed below: COMPANY.PRICESprodidprice producttype sales returnsK12S 5.10 NETWORK 15 2B132S 2.34 HARDWARE 300 10R18KY2 1.29 SOFTWARE 25 53KL8BY 6.37 HARDWARE 125 15DY65DW 5.60 HARDWARE 45 5DGTY23 4.55 HARDWARE 67 2The following SAS program is submitted:libnamecompany 'SAS-data-library';data hware inter soft;set company.prices (keep = producttype price);if price le 5.00;if producttype = 'HARDWARE' then output HWARE;else if producttype = 'NETWORK' then output INTER;else if producttype = 'SOFTWARE' then output SOFT;run;How many observations does the HWARE data set contain?A. 0B. 2C. 4D. 6Answer: BQUESTION 38The SASDATA.BANKS data set has five observations when the following SASprogram is submitted:libnamesasdata 'SAS-date-library';data allobs;set sasdata.banks;capital=0;do year = 2000 to 2020 by 5;capital + ((capital+2000) * rate);output;end;How many observations will the ALLOBS data set contain?A. 5B. 15C. 20D. 25Answer: DQUESTION 39A raw data file is listed below:----|----10---|----20---|----30John McCloskey 35 71June Rosesette 10 43TinekeJones 9 37The following SAS program is submitted using the raw data file as input: data work.homework;infile 'file-specification';input name $ age height;if age LE 10;run;How many observations will the WORK.HOMEWORK data set contain?A. 0B. 2C. 3D. No data set is created as the program fails to execute due to errors. Answer: CQUESTION 40The following SAS program is submitted:proc contents data = sasuser.airplanes;run;Which one of the following is produced as output?A. the data portion of every data set in the SASUSER libraryB. the data portion of the data set SASUSER.AIRPLANES onlyC. the descriptor portion of every data set in the SASUSER libraryD. the descriptor portion of the data set SASUSER.AIRPLANES onlyAnswer: DQUESTION 41The following SAS program is submitted:proc datasets lib = sasuser;contents data = class varnum;quit;Which one of the following is the purpose of the VARNUM option?A. to print a list of variable namesB. to print the total number of variablesC. to print a list of the variables in alphabetic orderD. to print a list of the variables in the order they were createdAnswer: DQUESTION 42Which one of the following SAS procedures displays the data portion of a SAS data set?A. PRINTB. FSLISTC. CONTENTSD. DATASETSAnswer: AQUESTION 43On which portion(s) of a SAS data set does the PRINT procedure report?A. the data portion onlyB. the descriptor portion onlyC. the descriptor portion and the data portionD. neither the data portion nor the descriptor portionAnswer: AQUESTION 44The following SAS program is submitted:data work.test;set work.staff (keep = jansales febsales marsales);array diff_sales{3} difsales1 - difsales3;array monthly{3} jansales febsales marsales;run;Which one of the following represents the new variables that are created?A. JANSALES, FEBSALES and MARSALESB. MONTHLY1, MONTHLY2 and MONTHLY3C. DIFSALES1, DIFSALES2 and DIFSALES3D. DIFF_SALES1, DIFF_SALES2 and DIFF_SALES3Answer: CQUESTION 45The following SAS program is submitted:data work.test;array agent{4} $ 12 sales1 - sales4;run;Which one of the following represents the variables that are contained in the outputdata set?A. SALES1, SALES2, SALES3, SALES4B. AGENTS1, AGENTS2, AGENTS3, AGENTS4C. None, the DATA step fails because the ARRAY statement can reference only numeric data.D. None, the DATA step fails because the ARRAY statement can reference onlypre-existing variables.Answer: AQUESTION 46The following SAS program is submitted:data stats;set revenue;array weekly{5} mon tue wed thus fri;<insert DO statement here>total = weekly{i} * .25;Which one of the following DO statements completes the program and processes the elements of the WEEKLY array?A. do i = 1 to 5;B. do weekly {i} = 1 to 5;C. do i = mon tue wed thu fri;D. A DO loop cannot be used because the variables referenced do not end in a digit. Answer: AQUESTION 47Which one of the following statements is true regarding the name of a SAS array?A. It is saved with the data set.B. It can be used in procedures.C. It exists only for the duration of the DATA step.D. It can be the same as the name of a variable in the data set.Answer: CQUESTION 48The observations in the SAS data set WORK.TEST are ordered by the values of the variable SALARY.The following SAS program is submitted:proc sort data = work.test out = work.testsorted;by name;run;Which one of the following is the result of the SAS program?A. The data set WORK.TEST is stored in ascending order by values of the NAME variable.B. The data set WORK.TEST is stored in descending order by values of the NAME variable.C. The data set WORK.TESTSORTED is stored in ascending order by values of the NAME variable.D. The data set WORK.TESTSORTED is stored in descending order by values of the NAME variable.Answer: CQUESTION 49The SAS data set WORK.AWARDS is listed below:fnamepointsAmy 2Amy 1Gerard 3Wang 3Wang 1Wang 2The following SAS program is submitted:proc sort data = work.awards;by descending fname points;run;Which one of the following represents how the observations are sorted?A. Wang 3Gerard 3Wang 2Amy 2Wang 1Amy 1B. Wang 3Wang 2Wang 1Gerard 3Amy 2Amy 1C. Wang 3Wang 1Wang 2Gerard 3Amy 2Amy 1D. Wang 1Wang 2Wang 3Gerard 3Amy 1Amy 2Answer: DQUESTION 50The SAS data set EMPLOYEE_INFO is listed below:IDNumberExpenses2542 100.003612 133.152198 234.342198 111.12The following SAS program is submitted:proc sort data = employee_info;<insert BY statement here>run;Which one of the following BY statements completes the program and sorts the data sequentially by ascending expense values within each ascending IDNUMBER value?A. by Expenses IDNumber;B. by IDNumber Expenses;C. by ascending (IDNumber Expenses);D. by ascending IDNumber ascending Expenses;Answer: BQUESTION 51The following SAS program is submitted:libnamecompany 'SAS-data-library';proc sort data = company.payroll;by EmployeeIDNumber;run;Write access has been granted to the COMPANY library.Which one of the following represents how the observations are sorted?A. COMPANY.PAYROLL is recreated in sorted order by EmployeeIDNumber.B. COMPANY.PAYROLL is stored in original order, and a new data set PAYROLL is created in sorted order by EmployeeIDNumber.C. COMPANY.PAYROLL is stored in original order, and a new data set COMPANY.PAYROLLSORTED is created in sorted order by EmployeeIDNumber.D. COMPANY.PAYROLL is recreated in sorted order by EmployeeIDNumber, and a new data set PAYROLL is created in sorted order by EmployeeIDNumber. Answer: AQUESTION 52The SAS data set QTR1_REVENUE is listed below:destination revenueYYZ 53634FRA 62129FRA 75962RDU 76254YYZ 82174The following SAS program is submitted:proc sort data = qtr1_revenue;by destination descending revenue;run;Which one of the following represents the first observation in the output data set?A. destination revenueYYZ 82174B. destination revenueYYZ 53634C. destination revenueFRA 62129D. destination revenueFRA 75962Answer: DThe SAS data set EMPLOYEE_INFO is listed below:IDNumberExpenses2542 100.003612 133.152198 234.342198 111.12The following SAS program is submitted:proc sort data = employee_info;<insert BY statement here>run;Which one of the following BY statements completes the program and sorts the data sequentially by descending expense values within each descending IDNUMBER value?A. by descending IDNumber Expenses;B. by (IDNumber Expenses) descending;C. by IDNumber descending Expenses descending;D. by descending IDNumber descending Expenses;Answer: DQUESTION 54The following SAS program is submitted:data work.new;length word $7;amount = 4;if amount = 4 then word = 'FOUR';else if amount = 7 then word = 'SEVEN';else word = 'NONE!!!';amount = 7;run;Which one of the following represents the values of the AMOUNT and WORD variables?A. amount word7 FOURB. amount word7 SEVENC. amount word4 FOURD. amount word4 ' ' (missing character value)Answer: A。

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

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

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=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 DepartmentD. Department Gender答案:A本题知识点:自动变量在SAS读取数据时,在PDV过程中会产生很多自动变量,在输出的数据集中是不可见的。

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

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

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

Q 2Given the following raw data records in TEXTFILE.TXT:----|----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,CurrentThe following output is desired:Obs Name Month Status Week1 Week2 Week3 Week4 Week51 John FEB Final $13 $25 $14 $27 .2 John MAR Current $26 $17 $29 $11 $233 Tina FEB Final $15 $18 $12 $13 .4 Tina MAR Current $29 $14 $19 $27 $20Which 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 Week5 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='MAR' then input Week1 Week2 Week3 Week4 Week5 Status $; format Week1-Week5 dollar6.;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 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 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给出选择项;· filespecification有以下三种形式:①、fileref(文件标志)②、’filename’(文件名)③、CARDS指明输入的数据,紧跟着CARDS语句· 下列选择项(options)可以出现在INFILE语句中:①、COLUMN=variable或COL=variable 定义一个变量, 其值是指针所在的当前列位置。

sas base

sas base

补充!!本人满分通过SAS base 考试。

经验分享。

@@SAS 认证试题人大SAS视频教程今天中午在hwy7 & warden HSBC tower 参加了SAS base 考试。

简单介绍一下考试70 道单选题,我总共用了30分钟完成考试。

要求65分pass。

本人取得满分100分。

我自己准备了3个星期。

不是很难。

考试界面跟pass4sure的界面一样。

所有的试题都在p ass4sure 的题库里。

成绩单请看下图。

相关材料:1.A00-211 Actualtests PDF (June 11,2008)70 题2.50题3.2008.09真题4.123题5.A00-201 (Killtest 30题)6.SAS认证220道_练习题及详细答案7.SAS online tutorial for base exam html版8.临考时候的补充材料9.SAS官方WEB培训教程—Prog I-1 SAS BASE PROGRAM II复习方法:先做50题2008.09真题。

这两个文件包含答案和具体解释。

然后结合SAS online tut orial for base exam html版具体学习和寻找答案。

SAS online tutorial for base exam html版是sas公司提供的在线官方教程431 美金!很有用的官方教程。

SAS认证220道_练习题及详细答案就是SAS online tutorial for ba se exam html版每章节后面的练习题然后做123题,A00-201 (Killtest 30题)和A00-211 Actualtests PDF (June 11,2008)70 题最后做pass4sure 的题库。

保证95分以上。

我就是按照这个方法考满分。

如果就是为了通过考试。

背会了pass4sure题库,A00-211 Actualtests PDF (June 11,2008)70 题,50题,2008.09真题也能保证95分以上。

SAS Base认证考试—70题(11-20)

SAS Base认证考试—70题(11-20)

SAS Base认证考试—70题(11-20)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 generate the following results:Analysis Variable : HeightNSex Age Obs Minimum Maximum Mean ------------------------------------------------------------------F Pre-Teen 3 51.3 59.8 55.8Teen 6 56.5 66.5 63.0M Pre-Teen 4 57.3 64.8 59.7 Teen 6 62.5 72.0 66.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 maxdec=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、STDDEV、SUM若不加统计关键词,默认打印的顺序:非缺失值个数(N)、均值(MEAN)、标准差(STDDEV)、最小值(MIN)、最大值(MAX)。

SAS认证220道_练习题及详细答案

SAS认证220道_练习题及详细答案

SAS Certificate Base Practice Questions and Detailed Answers Chapter 1: Basic ConceptsChapter 2: Referencing Files and Setting OptionsChapter 3: Editing and Debugging SAS ProgramsChapter 4: Creating List ReportsChapter 5: Creating SAS Data Sets from Raw DataChapter 6: Understanding DATA Step ProcessingChapter 7: Creating and Applying User-Defined FormatsChapter 8: Creating Enhanced List and Summary ReportsChapter 9: Producing Descriptive StatisticsChapter 10: Producing HTML OutputChapter 11: Creating and Managing VariablesChapter 12: Reading SAS Data SetsChapter 13: Combining SAS Data SetsChapter 14: Transforming Data with SAS FunctionsChapter 15: Generating Data with DO LoopsChapter 16: Processing Variables with ArraysChapter 17: Reading Raw Data in Fixed FieldsChapter 18: Reading Free-Format DataChapter 19: Reading Date and Time ValuesChapter 20: Creating a Single Observation from Multiple RecordsChapter 21: Creating Multiple Observations from a Single RecordChapter 22: Reading Hierarchical FilesChapter 1: Basic Concepts Answer Key1.How many observations and variables does the data set below contain?a. 3 observations, 4 variablesb. 3 observations, 3 variablesc. 4 observations, 3 variablesd.can't tell because some values are missingCorrect answer:cRows in the data set are called observations, and columns are called variables. Missing values don't affect the structure of the data set.2.How many program steps are executed when the program below is processed?data user.tables;infile jobs;input date name $ job $;run;proc sort data=user.tables;by name;run;proc print data=user.tables;run;a.threeb.fourc.fived.sixCorrect answer:aWhen it encounters a DATA, PROC, or RUN statement, SAS stops reading statements andexecutes the previous step in the program. The program above contains one DATA step and two PROC steps, for a total of three program steps.3.What type of variable is the variable AcctNum in the data set below?a.numericb.characterc.can be either character or numericd.can't tell from the data shownCorrect answer:bIt must be a character variable, because the values contain letters and underscores, which are not valid characters for numeric values.4.What type of variable is the variable Wear in the data set below?a.numericb.characterc.can be either character or numericd.can't tell from the data shownCorrect answer:aIt must be a numeric variable, because the missing value is indicated by a period rather than by a blank.5.Which of the following variable names is valid?a.4BirthDateb.$Costc._Items_d.Tax-RateCorrect answer:cVariable names follow the same rules as SAS data set names. They can be 1 to 32 characters long, must begin with a letter (A–Z, either uppercase or lowercase) or an underscore, and can continue with any combination of numbers, letters, or underscores.6.Which of the following files is a permanent SAS file?a.Sashelp.PrdSaleb.Sasuser.MySalesc.Profits.Quarter1d.all of the aboveCorrect answer:dTo store a file permanently in a SAS data library, you assign it a libref other than the default Work. For example, by assigning the libref Profits to a SAS data library, you specify that files within the library are to be stored until you delete them. Therefore, SAS files in the Sashelp and Sasuser libraries are permanent files.7.In a DATA step, how can you reference a temporary SAS data set named Forecast?a.Forecastb.Work.Forecastc.Sales.Forecast (after assigning the libref Sales)d.only a and b aboveCorrect answer:dTo reference a temporary SAS file in a DATA step or PROC step, you can specify the one-level name of the file (for example, Forecast) or the two-level name using the libref Work (for example, Work.Forecast).8.What is the default length for the numeric variable Balance?a. 5b. 6c.7d.8Correct answer:dThe numeric variable Balance has a default length of 8. Numeric values (no matter how many digits they contain) are stored in 8 bytes of storage unless you specify a different length.9.How many statements does the following SAS program contain?proc print data=new.prodsalelabel double;var state day price1 price2; where state='NC';label state='Name of State';run;a.threeb.fourc.fived.sixCorrect answer:cThe five statements are•PROC PRINT statement (two lines long)•VAR statement•WHERE statement (on the same line as the VAR statement)•LABEL statement•RUN statement (on the same line as the LABEL statement).10.What is a SAS data library?a. a collection of SAS files, such as SAS data sets and catalogsb.in some operating environments, a physical collection of SAS filesc.in some operating environments, a logically related collection of SAS filesd.all of the aboveCorrect answer:dEvery SAS file is stored in a SAS data library, which is a collection of SAS files, such as SAS data sets and catalogs. In some operating environments, a SAS data library is a physical collection of files. In others, the files are only logically related. In the Windows and UNIX environments, a SAS data library is typically a group of SAS files in the same folder or directory.Chapter 2: Referencing Files and Setting Options1.If you submit the following program, how does the output look?options pagesize=55 nonumber;proc tabulate data=clinic.admit;class actlevel;var age height weight;table actlevel,(age height weight)*mean;run;options linesize=80;proc means data=clinic.heart min max maxdec=1;var arterial heart cardiac urinary;class survive sex;run;a.The PROC MEANS output has a print line width of 80 characters, but the PROCTABULATE output has no print line width.b.The PROC TABULATE output has no page numbers, but the PROC MEANS outputhas page numbers.c.Each page of output from both PROC steps is 55 lines long and has no page numbers,and the PROC MEANS output has a print line width of 80 characters.d.The date does not appear on output from either PROC step.Correct: answer:cWhen you specify a system option, it remains in effect until you change the option or end your SAS session, so both PROC steps generate output that is printed 55 lines per page with no page numbers. If you don't specify a system option, SAS uses the default value for that system option.2.In order for the date values 05May1955 and 04Mar2046 to be read correctly, what value mustthe YEARCUTOFF= option have?a. a value between 1947 and 1954, inclusiveb.1955 or higherc.1946 or higherd.any valueCorrect answer:dAs long as you specify an informat with the correct field width for reading the entire date value, the YEARCUTOFF= option doesn't affect date values that have four-digit years.3.When you specify an engine for a library, you are always specifyinga.the file format for files that are stored in the library.b.the version of SAS that you are using.c.access to other software vendors' files.d.instructions for creating temporary SAS files.Correct answer:aA SAS engine is a set of internal instructions that SAS uses for writing to and reading from files in a SAS library. Each engine specifies the file format for files that are stored in the library, which in turn enables SAS to access files with a particular format. Some engines access SAS files, and other engines support access to other vendors' files.4.Which statement prints a summary of all the files stored in the library named Area51?a.proc contents data=area51._all_ nods;b.proc contents data=area51 _all_ nods;c.proc contents data=area51 _all_ noobs;d.proc contents data=area51 _all_.nods;Correct answer:aTo print a summary of library contents with the CONTENTS procedure, use a period to append the _ALL_ option to the libref. Adding the NODS option suppresses detailed information about the files.5.The following PROC PRINT output was created immediately after PROC TABULATEoutput. Which SAS system options were specified when the report was created?a.OBS=, DATE, and NONUMBERb.PAGENO=1, and DATEc.NUMBER and DATE onlyd.none of the aboveCorrect answer:bClearly, the DATE and PAGENO= options are specified. Because the page number on the output is 1, even though PROC TABULATE output was just produced. If you don't specify PAGENO=, all output in the Output window is numbered sequentially throughout your SAS session.6.Which of the following programs correctly references a SAS data set named SalesAnalysisthat is stored in a permanent SAS library?a.data saleslibrary.salesanalysis;set mydata.quarter1sales;if sales>100000;run;b.data mysales.totals;set sales_99.salesanalysis;if totalsales>50000;run;c.proc print data=salesanalysis.quarter1;var sales salesrep month;run;d.proc freq data=1999data.salesanalysis;tables quarter*sales; run;Correct answer:bLibrefs must be 1 to 8 characters long, must begin with a letter or underscore, and can contain only letters, numbers, or underscores. After you assign a libref, you specify it as the first element in the two-level name for a SAS file.7.Which time span is used to interpret two-digit year values if the YEARCUTOFF= option isset to 1950?a.1950-2049b.1950-2050c.1949-2050d.1950-2000Correct answer:aThe YEARCUTOFF= option specifies which 100-year span is used to interpret two-digit year values. The default value of YEARCUTOFF= is 1920. However, you can override the default and change the value of YEARCUTOFF= to the first year of another 100-year span. If you specify YEARCUTOFF=1950, then the 100-year span will be from 1950 to 2049.8.Asssuming you are using SAS code and not special SAS windows, which one of thefollowing statements is false?a.LIBNAME statements can be stored with a SAS program to reference the SAS libraryautomatically when you submit the program.b.When you delete a libref, SAS no longer has access to the files in the library.However, the contents of the library still exist on your operating system.c.Librefs can last from one SAS session to another.d.You can access files that were created with other vendors' software by submitting aLIBNAME statement.Correct answer:cThe LIBNAME statement is global, which means that librefs remain in effect until you modify them, cancel them, or end your SAS session. Therefore, the LIBNAME statement assigns the libref for the current SAS session only. You must assign a libref before accessingSAS files that are stored in a permanent SAS data library.9.What does the following statement do?libname osiris spss 'c:\myfiles\sasdata\data';a.defines a library called Spss using the OSIRIS engineb.defines a library called Osiris using the SPSS enginec.defines two libraries called Osiris and Spss using the default engined.defines the default library using the OSIRIS and SPSS enginesCorrect answer:bIn the LIBNAME statement, you specify the library name before the engine name. Both are followed by the path.10.What does the following OPTIONS statement do?options pagesize=15 nodate;a.suppresses the date and limits the page size of the logb.suppresses the date and limits the vertical page size for text outputc.suppresses the date and limits the vertical page size for text and HTML outputd.suppresses the date and limits the horizontal page size for text outputCorrect answer:bThese options affect the format of listing output only. NODATE suppresses the date and PAGESIZE= determines the number of rows to print on the page.Chapter 3: Editing and Debugging SAS Programs Answer Key1.As you write and edit SAS programs it's a good idea toa.begin DATA and PROC steps in column one.b.indent statements within a step.c.begin RUN statements in column one.d.all of the aboveCorrect answer:dAlthough you can write SAS statements in almost any format, a consistent layout enhances readability and enables you to understand the program's purpose. It's a good idea to begin DATA and PROC steps in column one, to indent statements within a step, to begin RUN statements in column one, and to include a RUN statement after every DATA step or PROC step.2.What usually happens when an error is detected?a.SAS continues processing the step.b.SAS continues to process the step, and the log displays messages about the error.c.SAS stops processing the step in which the error occurred, and the log displaysmessages about the error.d.SAS stops processing the step in which the error occurred, and the program outputdisplays messages about the error.Correct answer:cSyntax errors generally cause SAS to stop processing the step in which the error occurred. When a program that contains an error is submitted, messages regarding the problem also appear in the SAS log. When a syntax error is detected, the SAS log displays the word ERROR, identifies the possible location of the error, and gives an explanation of the error.3. A syntax error occurs whena.some data values are not appropriate for the SAS statements that are specified in aprogram.b.the form of the elements in a SAS statement is correct, but the elements are not validfor that usage.c.program statements do not conform to the rules of the SAS language.d.none of the aboveCorrect canswer:Syntax errors are common types of errors. Some SAS system options, features of the Editorwindow, and the DATA step debugger can help you identify syntax errors. Other types oferrors include data errors, semantic errors, and execution-time errors.4.How can you tell whether you have specified an invalid option in a SAS program?a. A log message indicates an error in a statement that seems to be valid.b. A log message indicates that an option is not valid or not recognized.c.The message "PROC running" or "DATA step running" appears at the top of theactive window.d.You can't tell until you view the output from the program.Correct answer:bWhen you submit a SAS statement that contains an invalid option, a log message notifies you that the option is not valid or not recognized. You should recall the program, remove or replace the invalid option, check your statement syntax as needed, and resubmit the corrected program.5.Which of the following programs contains a syntax error?Correct answer:bThe DATA step contains a misspelled keyword (dat instead of data). However, this is such a common (and easily interpretable) error that SAS produces only a warning message, not an error.6.What does the following log indicate about your program?proc print data=sasuser.cargo99var origin dest cargorev;2276ERROR 22-322: Syntax error, expecting one of the following:;, (, DATA, DOUBLE, HEADING, LABEL, N, NOOBS, OBS, ROUND, ROWS, SPLIT, STYLE,UNIFORM, WIDTH.ERROR 76-322: Syntax error, statement will be ignored.11 run;a.SAS identifies a syntax error at the position of the VAR statement.b.SAS is reading VAR as an option in the PROC PRINT statement.c.SAS has stopped processing the program because of errors.d.all of the aboveCorrect answer:dBecause there is a missing semicolon at the end of the PROC PRINT statement, SAS interprets VAR as an option in PROC PRINT and finds a syntax error at that location. SAS stops processing programs when it encounters a syntax error.Chapter 4: Creating List Reports Answer Key 1.Which PROC PRINT step below creates the following output?Correct answer:cThe DATA= option specifies the data set that you are listing, and the ID statement replaces the Obs column with the specified variable. The VAR statement specifies variables and controls the order in which they appear, and the WHERE statement selects rows based on a condition. The LABEL option in the PROC PRINT statement causes the labels that are specified in the LABEL statement to be displayed.2.Which of the following PROC PRINT steps is correct if labels are not stored with thedata set?Correct aanswer:You use the DATA= option to specify the data set to be printed. The LABEL optionspecifies that variable labels appear in output instead of variable names.3.Which of the following statements selects from a data set only those observations forwhich the value of the variable Style is RANCH, SPLIT, or TWOSTORY?Correct answer:dIn the WHERE statement, the IN operator enables you to select observations based on several values. You specify values in parentheses and separate them by spaces or commas. Character values must be enclosed in quotation marks and must be in the same case as in the data set.4.If you want to sort your data and create a temporary data set named Calc to store thesorted data, which of the following steps should you submit?Correct answer:cIn a PROC SORT step, you specify the DATA= option to specify the data set to sort. The OUT= option specifies an output data set. The required BY statement specifies the variable(s) to use in sorting the data.5.Which options are used to create the following PROC PRINT output?13:27 Monday, March 22, 1999 Patient Arterial Heart Cardiac Urinary203 88 95 66 11054 83 183 95 0664 72 111 332 12210 74 97 369 0101 80 130 291 0a.the DATE system option and the LABEL option in PROC PRINTb.the DATE and NONUMBER system options and the DOUBLE and NOOBSoptions in PROC PRINTc.the DATE and NONUMBER system options and the DOUBLE option inPROC PRINTd.the DATE and NONUMBER system options and the NOOBS option in PROCPRINTCorrect answer:bThe DATE and NONUMBER system options cause the output to appear with the date but without page numbers. In the PROC PRINT step, the DOUBLE option specifies double spacing, and the NOOBS option removes the default Obs column.6.Which of the following statements can you use in a PROC PRINT step to create thisoutput?Correct answer:dYou do not need to name the variables in a VAR statement if you specify them in the SUM statement, but you can. If you choose not to name the variables in the VAR statement as well, then the SUM statement determines the order of the variables in the output.7.What happens if you submit the following program?proc sort data=clinic.diabetes;run;proc print data=clinic.diabetes;var age height weight pulse;where sex='F';run;a.The PROC PRINT step runs successfully, printing observations in their sortedorder.b.The PROC SORT step permanently sorts the input data set.c.The PROC SORT step generates errors and stops processing, but the PROCPRINT step runs successfully, printing observations in their original (unsorted)order.d.The PROC SORT step runs successfully, but the PROC PRINT step generateserrors and stops processing.Correct answer:cThe BY statement is required in PROC SORT. Without it, the PROC SORT step fails. However, the PROC PRINT step prints the original data set as requested.8.If you submit the following program, which output does it create?proc sort data=finance.loans out=work.loans;by months amount;run;proc print data=work.loans noobs; var months;sum amount payment;where months<360;run;a.b.c.d.Correct answer:aColumn totals appear at the end of the report in the same format as the values of the variables, so b is incorrect. Work.Loans is sorted by Month and Amount, so c isincorrect. The program sums both Amount and Payment, so d is incorrect.9.Choose the statement below that selects rows which•the amount is less than or equal to $5000•the account is 101-1092 or the rate equals 0.095.Correct answer:cTo ensure that the compound expression is evaluated correctly, you can use parentheses to groupaccount='101-1092' or rate eq 0.095OBS Account Amount Rate MonthsPayment1 101-1092 $22,000 10.00%60 $467.432 101-1731 $114,0009.50% 360 $958.573 101-1289 $10,000 10.50%36 $325.024 101-3144 $3,500 10.50%12 $308.525 103-1135 $8,700 10.50%24 $403.476 103-1994 $18,500 10.00%60 $393.077 103-2335 $5,000 10.50%48 $128.028 103-3864 $87,500 9.50% 360 $735.759 103-3891 $30,000 9.75% 360 $257.75For example, from the data set above, a and b above select observations 2 and 8 (those that have a rate of 0.095); c selects no observations; and d selects observations 4 and 7 (those that have an amount less than or equal to 5000).10.What does PROC PRINT display by default?a.PROC PRINT does not create a default report; you must specify the rows andcolumns to be displayed.b.PROC PRINT displays all observations and variables in the data set. If youwant an additional column for observation numbers, you can request it.c.PROC PRINT displays columns in the following order: a column forobservation numbers, all character variables, and all numeric variables.d.PROC PRINT displays all observations and variables in the data set, a columnfor observation numbers on the far left, and variables in the order in which they occur in the data set.Correct answer:dYou can remove the column for observation numbers. You can also specify the variables you want, and you can select observations according to conditions.Chapter 5: Creating SAS Data Sets from Raw Data Answer Key1.Which SAS statement associates the fileref Crime with the raw data fileC:\States\Data\Crime?a.filename crime 'c:\states\data\crime';b.filename crime c:\states\data\crime;c.fileref crime 'c:\states\data\crime';d.filename 'c:\states\data\crime' crime; Correct aanswer:Before you can read your raw data, you must reference the raw data file by creating afileref. You assign a fileref by using a FILENAME statement in the same way thatyou assign a libref by using a LIBNAME statement.2.Filerefs remain in effect untila.you change them.b.you cancel them.c.you end your SAS session.d.all of the aboveCorrect answer:dLike LIBNAME statements, FILENAME statements are global; they remain in effect until you change them, cancel them, or end your SAS session.3.Which statement identifies the name of a raw data file to be read with the filerefProducts and specifies that the DATA step read only records 1-15?a.infile products obs 15;b.infile products obs=15;c.input products obs=15;d.input products 1-15;Correct answer:bYou use an INFILE statement to specify the raw data file to be read. You can specify a fileref or an actual filename (in quotation marks). The OBS= option in the INFILE statement enables you to process only records 1 through n.4.Which of the following programs correctly writes the observations from the data setbelow to a raw data file?Correct answer:dThe keyword _NULL_ in the DATA statement enables you to use the power of the DATA step without actually creating a SAS data set. You use the FILE and PUT statements to write out the observations from a SAS data set to a raw data file. The FILE statement specifies the raw data file and the PUT statement describes the lines towrite to the raw data file. The filename and location that are specified in the FILE statement must be enclosed in quotation marks.5.Which raw data file can be read using column input?a.b.c.d.all of the aboveCorrect answer:bColumn input is appropriate only in some situations. When you use column input, your data must be standard character or numeric values, and they must be in fixed fields. That is, values for a particular variable must be in the same location in all records.6.Which program creates the output shown below?Correct answer:aThe INPUT statement creates a variable using the name that you assign to each field. Therefore, when you write an INPUT statement, you need to specify the variable names exactly as you want them to appear in the SAS data set.7.Which statement correctly reads the fields in the following order: StockNumber,Price, Item, Finish, Style?Field Name Start Column End Column Data TypeStockNumber 1 3 characterFinish 5 9 characterStyle 11 18 characterItem 20 24 characterPrice 27 32 numericCorrec t answer:bYou can use column input to read fields in any order. You must specify the variable name to be created, identify character values with a $, and name the correct starting column and ending column for each field.8.Which statement correctly re-defines the values of the variable Income as 100percent higher?a.income=income*1.00;b.income=income+(income*2.00);c.income=income*2;d.income=*2;Correct answer:cTo re-define the values of the variable Income in an Assignment statement, you specify the variable name on the left side of the equal sign and an appropriate expression including the variable name on the right side of the equal sign.9.Which program correctly reads instream data?a.data finance.newloan;input datalines;if country='JAPAN';MonthAvg=amount/12;1998 US CARS 194324.121998 US TRUCKS 142290.301998 CANADA CARS 10483.441998 CANADA TRUCKS 93543.641998 MEXICO CARS 22500.571998 MEXICO TRUCKS 10098.881998 JAPAN CARS 15066.431998 JAPAN TRUCKS 40700.34;b.data finance.newloan;input Year 1-4 Country $ 6-11Vehicle $ 13-18 Amount 20-28;if country='JAPAN';MonthAvg=amount/12;datalines;run;c.data finance.newloan;input Year 1-4 Country 6-11Vehicle 13-18 Amount 20-28;if country='JAPAN';MonthAvg=amount/12;datalines;1998 US CARS 194324.121998 US TRUCKS 142290.301998 CANADA CARS 10483.441998 CANADA TRUCKS 93543.641998 MEXICO CARS 22500.571998 MEXICO TRUCKS 10098.881998 JAPAN CARS 15066.431998 JAPAN TRUCKS 40700.34;d.data finance.newloan;input Year 1-4 Country $ 6-11Vehicle $ 13-18 Amount 20-28;if country='JAPAN';MonthAvg=amount/12;datalines;1998 US CARS 194324.121998 US TRUCKS 142290.301998 CANADA CARS 10483.441998 CANADA TRUCKS 93543.641998 MEXICO CARS 22500.571998 MEXICO TRUCKS 10098.881998 JAPAN CARS 15066.431998 JAPAN TRUCKS 40700.34;Correct answer:dTo read instream data, you specify a DATALINES statement and data lines, followed by a null statement (single semicolon) to indicate the end of the input data. Program a contains no DATALINES statement, and the INPUT statement doesn't specify the fields to read. Program b contains no data lines, and the INPUT statement in program c doesn't specify the necessary dollar signs for the character variables Country and Vehicle.10.Which SAS statement subsets the raw data shown below so that only the observationsin which Sex (in the second field) has a value of F are processed?a.if sex=f;b.if sex=F;c.if sex='F';d. a or bCorrect answer:cTo subset data, you can use a subsetting IF statement in any DATA step to process only those observations that meet a specified condition. Because Sex is a character variable, the value F must be enclosed in quotation marks and must be in the same case as in the data set.Chapter 6: Understanding DATA Step Processing Answer Key1.Which of the following is not created during the compilation phase?。

SAS上机练习题全部含参考答案

SAS上机练习题全部含参考答案

重庆医科大学--卫生统计学统计软件包SAS上机练习题(一)1、SAS常用的窗口有哪三个?请在三个基本窗口之间切换并记住这些命令或功能键。

2、请在PGM窗口中输入如下几行程序,提交系统执行,并查看OUTPUT窗和LOG窗中内容,注意不同颜色的含义;并根据日志窗中的信息修改完善程序。

3、将第2题的程序、结果及日志保存到磁盘。

4、试根据如下例1的程序完成后面的问题:表1 某班16名学生3门功课成绩表如下问题:1)建立数据集;2)打印至少有1门功课不及格同学的信息;(提示,使用if语句)参考程序:data a;input id sh wl bl;cards;083 68 71 65084 74 61 68085 73 75 46086 79 80 79087 75 71 68084 85 85 87085 78 79 75086 80 76 79087 85 80 82088 77 71 75089 67 73 71080 75 81 70118 70 54 75083 70 66 84084 62 73 65099 82 70 79;run;data b;set a;if sh<60 or wl<60 or bl<60then output;run;proc print data=b;var id sh wl bl;run;5、根据下列数据建立数据集表2销售数据开始时间终止时间费用2005/04/28 25MAY2009 $123,345,0002005 09 18 05OCT2009 $33,234,5002007/08/12 22SEP2009 $345,600提示:(计算,如果读入错误,可试着调整格式的宽度;显示日期需要使用输出格式) 开始时间,输入格式yymmdd10.终止时间,输入格式date10.费用,输入格式dollar12.参考程序:data a;input x1 yymmdd10. x2 date10. x3 dollar13.;cards;2005/04/28 25MAY2009 $123,345,0002005 09 18 05OCT2009 $33,234,5002007/08/12 22SEP2009 $345,60020040508 30JUN2009 $432,334,500;run;proc print;run;proc print;format x1 yymmdd10. x2 date9. x3 dollar13.;run;6、手机号码一编码规则一般是:YYY-XXXX-ZZZZ,其YYY为号段;XXXX一般为所在地区编码;ZZZZ为对应的个人识别编号。

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

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

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=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 DepartmentD. Department Gender答案:A本题知识点:自动变量在SAS读取数据时,在PDV过程中会产生很多自动变量,在输出的数据集中是不可见的。

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

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

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

Q 2Given the following raw data records in TEXTFILE.TXT:----|----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,CurrentThe following output is desired:Obs Name Month Status Week1 Week2 Week3 Week4 Week51 John FEB Final $13 $25 $14 $27 .2 John MAR Current $26 $17 $29 $11 $233 Tina FEB Final $15 $18 $12 $13 .4 Tina MAR Current $29 $14 $19 $27 $20Which 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 Week5 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='MAR' then input Week1 Week2 Week3 Week4 Week5 Status $; format Week1-Week5 dollar6.;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 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 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给出选择项;· filespecification有以下三种形式:①、fileref(文件标志)②、’filename’(文件名)③、CARDS指明输入的数据,紧跟着CARDS语句· 下列选择项(options)可以出现在INFILE语句中:①、COLUMN=variable或COL=variable 定义一个变量, 其值是指针所在的当前列位置。

SAS练习题及程序答案

SAS练习题及程序答案

1.随机取组有无重复试验的两种本题是无重复DATA PGM15G;DO A=1TO4; /*A为窝别*/DO B=1TO3; /*B为雌激素剂量*/INPUT X @@; /*X为子宫重量*/OUTPUT;END;END;CARDS;106 116 14542 68 11570 111 13342 63 87;RUN;ods html; /*将结果输出成网页格式,SAS9.0以后版本可用*/ PROC GLM DATA=PGM15G;CLASS A B;MODEL X=A B / SS3;MEANS A B; /*给出因素A、B各水平下的均值和标准差*/MEANS B / SNK; /*对因素B(即剂量)各水平下的均值进行两两比较*/ RUN;ODS HTML CLOSE;2.2*3析因设计两因素完全随机统计方法2*3析因设计tiff =f的开方DATA aaa;DO zs=125,200;DO repeat=1TO2; /*每种试验条件下有2次独立重复试验*/do js=0.015,0.030,0.045;INPUT cl @@;OUTPUT;END;END;END;CARDS;2.70 2.45 2.602.78 2.49 2.722.83 2.85 2.862.86 2.80 2.87;run;PROC GLM;CLASS zs js;MODEL cl=zs js zs*js / SS3;MEANS zs*js;LSMEANS zs*js / TDIFF PDIFF; /*对 zs和js各水平组合而成的试验条件进行均数进行两两比较*/RUN;ODS HTML CLOSE;练习一:2*2横断面研究列链表方法:卡方矫正卡方FISHERDATA PGM19A;DO A=1TO2;DO B=1TO2;INPUT F @@;OUTPUT;END;END;CARDS;2 268 21;run;PROC FREQ;WEIGHT F;TABLES A*B / CHISQ;RUN;样本大小= 57练习二:对裂列连表结果变量换和不换三部曲1横断面研究P《0.05 RDATA PGM19B;DO A=1TO2;DO B=1TO2;INPUT F @@;OUTPUT;END;END;CARDS;40 34141 19252;run;ods html;PROC FREQ;WEIGHT F;TABLES A*B / CHISQ cmh;RUN;ods html close;样本大小= 57练习三:病例对照2*2 病例组中有何没有那个基因是正常的3.8倍,则有可能导致痴呆要做前瞻性研究用对裂DATA PGM20;DO A=1TO2;DO B=1TO2;INPUT F @@;OUTPUT;END;END;CARDS;240 60360 340;run;ods html;PROC FREQ;WEIGHT F;TABLES A*B / CHISQ cmh;RUN;ods html close;总样本大小= 1000练习四:配对设计隐含金标准2*2 MC卡方检验34和0在总体上(B+C《40 用矫正卡方)是否相等则可得甲培养基优于乙培养基一般都用矫正因卡方为近似计算DATA PGM19F;INPUT b c;chi=(ABS(b-c)-1)**2/(b+c);p=1-PROBCHI(chi,1);求概率 1减掉从左侧积分到卡方的值chi=ROUND(chi, 0.001);IF p>0.0001THEN p=ROUND(p,0.0001);FILE PRINT;PUT(打印在输出床口) #2 @10'Chisq' @30'P value'(#表示行)#4 @10 chi @30 p;CARDS;34 0;run;ods html close;练习五:双向有序R*C列连表用KPA data aaa;do a=1to3;do b=1to3;input f @@;output;end;end;cards;58 2 31 42 78 9 17;run;ods html;*简单kappa检验;proc freq data=aaa;weight f;(频数)tables a*b;test kappa;run;*加权kappa检验;proc freq;weight f;tables a*b;test wtkap;run;SASFREQ 过程a *b 表的统计量对称性检验指总体上主对角线的上三角数相加是否与下三角三个数相加对称性检验与KPA 检验是否一致是否一个可以代替另一个检验Pe理论观察一致率独立假设性基础上计算的相互独立总体的KPA 是否为0 KPA 大于0两种方法的一致性有统计学意义 小于0 不一致性有统计学意义置信区间不包括0 拒绝H0 但要看专业要求达到多少才可以 观测一致率达到多少才可以代替 样本大小 = 147FREQ 过程a *b 表的统计量对加权的KPA检验与简单的(利用对角线上的数据分析)加权还要利用对角线以外的数据分析样本大小= 147练习六:双向无序R*C 列连表用卡方理论频数小于5没有超过五分之一,一般用卡方实在不行用FISHER检验超过用KPA 两种血型都是按小中大排列相互不影响独立的接受H0 不一致行与列变量相互不影响DATA PGM20A;DO A=1TO4;DO B=1TO3;INPUT F @@;OUTPUT;END;END;CARDS;431 490 902388 410 800495 587 950137 179 325;run;ods html;PROC FREQ;WEIGHT F;TABLES A*B / CHISQ;*exact;RUN;ods html close;样本大小= 6094练习七:单向有序R*C 秩和检验*方法1;(单因素非参数 HO三个药物疗效相同 H1不完全相等)DATA PGM20C;DO A=1TO4;DO B=1TO3;INPUT F @@;OUTPUT;END;END;CARDS;15 4 149 9 1531 50 455 22 24;run;ods html;PROC NPAR1WAY WILCOXON;FREQ F;CLASS B;VAR A;RUN;*方法2;(FIQ CHIM)proc freq data=PGM20C;weight f;tables b*a/cmh scores=rank;run;ods html close;总样本大小= 270练习八:双向有序属性不同R*C 4种目的4种方法SPEARMAN秩相关分析DATA PGM20E;DO A=1TO3;DO B=1TO3;INPUT F @@;OUTPUT;END;END;CARDS;215 131 14867 101 12844 63 132;run;ods html;PROC CORR SPEARMAN;VAR A B;FREQ F;RUN;ods html close;统计分析与SAS实现第1次上机实习题一、定量资料上机实习题要求:(1)先判断定量资料所对应的实验设计类型;(2)假定资料满足参数检验的前提条件,请选用相应设计的定量资料的方差分析,并用SAS软件实现统计计算;(3)摘录主要计算结果并合理解释,给出统计学结论和专业结论。

SAS-Base认证考试—70题(21-30)

SAS-Base认证考试—70题(21-30)

SAS-Base 认证考试—70题(21-30)此题知识点: IF 子集、 OUPUT 语句子集 IF 语句对知足条件的观察输出到正在被创立的数据集中。

Q 22Which step displays a listing of all the data sets in the WORK library?A. proc contents lib=WORK run;B.proc contents lib=WORK.all;run;C. proc contents data=WORK._all_; run;D. proc contents data=WORK _ALL_; run; 答案: C此题知识点: PROC CONTENTS过程默认自动打印近来创立的数据集的描绘信息PROC CONTENTS;RUN;打印目前目录下的所有数据集的描绘信息PROC CONTENTS DATA=_ALL_;RUN;打印 WORK暂时逻辑库下数据集的描绘信息PROC CONTENTSDATA=WORK._ALL_;RUN;Q 23Which is a valid LIBNAME statement?A. libname "_SAS_data_library_location_";B. sasdata libname"_SAS_data_library_location_";C. libname sasdata"_SAS_data_library_location_";D. libname sasdata sas"_SAS_data_library_location_";答案: C此题知识点: LIBNAME定义逻辑库参照第 12 题。

Q 24Given the following raw data records:----|----10---|----20---|----30Susan*12/29/1970*10Michael**6The following output is desired:Obs employee bdate years1Susan4015102Michael.6Which SAS program correctly reads in the raw data?A. data employees;infile 'file specification' dlm='*';input employee $ bdate : mmddyy10. years;run;B. data employees;infile 'file specification' dsd='*';input employee $ bdate mmddyy10. years;run;C. data employees;infile 'file specification' dlm dsd;input employee $ bdate mmddyy10. years;run;D. data employees;infile 'file specification' dlm='*' dsd;input employee $ bdate : mmddyy10. years;run;答案: D此题知识点: INFILE语句参照第 2 题。

SAS练习题及答案

SAS练习题及答案

1.SAS系统主要完成以数据为中心的四大功能,其中核心功能为:统计分析功能2.在SAS系统的组成模块中,能进行数据管理和数据加工、处理的模块……BASE模块3.SAS显示管理系统窗口中能够提交当前运行的SAS程序执行过程的窗口为:…………………………………………………………………PGM窗口4.如下一段SAS程序:DATA ;INPUT X @@;CARDS:2 3 4 9 1 ;RUN;模块当运行程序以后SAS系统会产生SAS数据集………………………………………( C )A. DATAB. NULLC. DATA1D.程序错误5.INPUT语句一般用来指定数据的读入方式,可以读取各种类型的数据包括字符型,现有如下的一段程序:DATA ONE;INPUT NAME $ SCORE;CARDS;Wanglin 85Zhang dong-feng 90;那么在第二个观测中读取到的NAME 为……………………………………………(B)A. Zhang dong-fengB. ZhangC. Zhang doD. Zhang dong6.假设变量X的值为5,有如下程序IF X<5 THENX=X+3;ELSEX=X-2;则执行程序以后变量X的值为………………………………………………………( B)A. 5B.3C.8D. 程序错误7.DATA TEST;DO I=1 TO 3;PUT I= ;END;RUN;程序结果在LOG窗口输出形式为……………………………………………………( A )A. I=1 I=2 I=3B.I=2 I=3 I=4C. 不显示D. I=3 I=2 I=18.假设变量X1=-10.253 X2=-5 则[SIGN(X1)+ABS(X2)]/INT(X1)的运算结果为………………………………………( B)A.-4B.-0.4C. 4D.0.5759.逻辑运算[(5<1)|(4<>2)]&(7>2)的结果为:……………………………………( 1 )10.以下几个统计量在UNIVARIATE过程中能求得到得而在MEANS过程中无法求得的是………………………………………………………………………………………( B )A. meanB. varC. Q1D.range11.SAS系统主要完成以数据为中心的四大功能,其中能够将Excel、Lotus、DBF、TXT等数据转化成SAS 数据集属于…………………………… (数据管理功能 )12. SAS数据集是关系型结构,分成两部分:描述部分和。

SAS_base_考试必备_70真题(附答案)

SAS_base_考试必备_70真题(附答案)

1.The following SAS program is submitted:data WORK.TOTAL;set WORK.SALARY;by Department Gender;if First.<_insert_code_> then Payroll=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 DepartmentD. Department GenderAnswer: A-------------------------------------2.Given the following raw data records in TEXTFILE.TXT:----|----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,CurrentThe following output is desired:Obs Name Month Status Week1 Week2 Week3 Week4 Week51 John FEB Final $13 $25 $14 $27 .2 John MAR Current $26 $17 $29 $11 $233 Tina FEB Final $15 $18 $12 $13 .4 Tina MAR Current $29 $14 $19 $27 $20 Which 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 Week5 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='MAR' then input Week1 Week2 Week3 Week4 Week5 Status $;format Week1-Week5 dollar6.;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 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 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;Answer: C-------------------------------------3.The 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 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;Answer: D-------------------------------------4.The 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. a missing value due to syntax errorsD. the step will not compile because of the character argument in the mdy function.Answer: A-------------------------------------5.Which 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' stop@10;C. infile 'customer.txt' obs=10;D. input 'customer.txt' stop=10;Answer: C-------------------------------------6.After 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' 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,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;Answer: D-------------------------------------7.Which of the following choices is an unacceptable ODS destination for producing output that can be viewed in Microsoft Excel?A. MSOFFICE2KB. EXCELXPC. CSVALLD. WINXPAnswer: D-------------------------------------8.The SAS data set named 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.Department=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.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.SALARY data set.Answer: C-------------------------------------10.The 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 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 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.Answer: C 因为有一个$符号-------------------------------------11.Given 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 generate the following results:Analysis Variable : HeightNSex Age Obs Minimum MaximumMean------------------------------------------------------------------F Pre-Teen 3 51.3 59.8 55.8Teen 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 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;Answer: C-------------------------------------12.The Excel workbook QTR1.XLS contains the following three worksheets:JANFEBMARWhich statement correctly 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);Answer: A-------------------------------------13.The following SAS program is submitted:data WORK.TEST;set WORK.MEASLES(keep=Janpt Febpt Marpt);array Diff{3} Difcount1-Difcount3;array Patients{3} 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 Patients3Answer: A-------------------------------------14.Which 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 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='NE' then description='Central';run;Answer: c-------------------------------------15.Which 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.Answer: D-------------------------------------16.The following SAS program is submitted:data WORK.DATE_INFO;X='04jul2005'd;DayOfMonth=day(x);MonthOfYear=month(x);Year=year(x);run;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.Answer: B-------------------------------------17.Given 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 data step execution, what will data set WORK.GEO contain?A.City State Region----------- ----- -------Tulsa OK WesternLos Angeles CA WesternBangor WesternB.City State Region----------- ----- -------Tulsa OK WesternLos Angeles CA WesternBangorC.City State Region----------- ----- -------Tulsa OK CentralLos Angeles CA WesternBangor WesternD.City State Region----------- ----- -------Tulsa OK CentralLos CA WesternBangorAnswer: A-------------------------------------18.Which 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 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.Answer: C-------------------------------------19.The SAS data set WORK.ONE contains a numeric variable named Num and a character variable named Char:WORK.ONENum Char--- ----1 233 231 77The following SAS program is submitted:proc print data=WORK.ONE;where Num='1';run;What is output?A.Num Char--- ----1 23B.Num Char--- ----1 231 77C.Num Char--- ----1 233 231 77D. No output is generated.Answer: D-------------------------------------20. The data set WORK.REALESTATE has the variable LocalFee with a format of 9. and a variable CountryFee with a format of 7.;The following SAS program is submitted:data WORK.FEE_STRUCTURE;format LocalFee CountryFee percent7.2;set WORK.REALESTAT;LocalFee=LocalFee/100;CountryFee=CountryFee/100;run;What are the formats of the variables LOCALFEE and COUNTRYFEE in the output dataset?A. LocalFee has format of 9. and CountryFee has a format of 7.B. LocalFee has format of 9. and CountryFee has a format of percent7.2C. Both LocalFee and CountryFee have a format of percent7.2D. The data step fails execution; there is no format for LocalFee.Answer: C-------------------------------------21.Given the SAS data set WORK.PRODUCTS:ProdId Price ProductType Sales Returns------ ----- ----------- ----- -------K12S 95.50 OUTDOOR 15 2B132S 2.99 CLOTHING 300 10R18KY2 51.99 EQUIPMENT 25 53KL8BY 6.39 OUTDOOR 125 15DY65DW 5.60 OUTDOOR 45 5DGTY23 34.55 EQUIPMENT 67 2The following SAS program is submitted:data WORK.OUTDOOR WORK.CLOTH WORK.EQUIP;set WORK.PRODUCTS;if Sales GT 30;if ProductType EQ 'OUTDOOR' then output WORK.OUTDOOR;else if ProductType EQ 'CLOTHING' then output WORK.CLOTH;else if ProductType EQ 'EQUIPMENT' then output WORK.EQUIP; run;How many observations does the WORK.OUTDOOR data set contain?A. 1B. 2C. 3D. 6Answer: B-------------------------------------22.Which step displays a listing of all the data sets in the WORK library?A. proc contents lib=WORK run;B. proc contents lib=WORK.all;run;C. proc contents data=WORK._all_; run;D. proc contents data=WORK _ALL_; run;Answer: c-------------------------------------23.Which is a valid LIBNAME statement?A. libname "_SAS_data_library_location_";B. sasdata libname "_SAS_data_library_location_";C. libname sasdata "_SAS_data_library_location_";D. libname sasdata sas "_SAS_data_library_location_";Answer: C-------------------------------------24.Given the following raw data records:----|----10---|----20---|----30Susan*12/29/1970*10Michael**6The following output is desired:Obs employee bdate years1 Susan 4015 102 Michael . 6Which SAS program correctly reads in the raw data?A.data employees;infile 'file specification' dlm='*';input employee $ bdate : mmddyy10. years;run;B.data employees;infile 'file specification' dsd='*';input employee $ bdate mmddyy10. years;run;C.data employees;infile 'file specification' dlm dsd;input employee $ bdate mmddyy10. years;run;D.data employees;infile 'file specification' dlm='*' dsd;input employee $ bdate : mmddyy10. years;run;Answer: D-------------------------------------25.Given the following code:proc print data=SASHELP.CLASS(firstobs=5 obs=15);where Sex='M';run;How many observations will be displayed?A. 11B. 15C. 10 or fewerD. 11 or fewerAnswer: D-------------------------------------26.Which step sorts the observations of a permanent SAS data set by two variables and stores the sorted observations in a temporary SAS data set?A.proc sort out=EMPLOYEES data=EMPSORT;by Lname and Fname;run;B.proc sort data=SASUSER.EMPLOYEES out=EMPSORT;by Lname Fname;run;C.proc sort out=SASUSER.EMPLOYEES data=WORK.EMPSORT;by Lname Fname;run;D.proc sort data=SASUSER.EMPLOYEES out=SASUSER.EMPSORT;by Lname and Fname;run;Answer: B-------------------------------------27.Given the SAS data set WORK.TEMPS:Day Month Temp--- ----- ----1 May 7515 May 7015 June 803 June 762 July 8514 July 89The following program is submitted: proc sort data=WORK.TEMPS;by descending Month Day; run;proc print data=WORK.TEMPS; run;Which output is correct?A.Obs Day Month Temp --- --- ----- ----1 2 July 852 14 July 893 3 June 764 15 June 805 1 May 756 15 May 7B.Obs Day Month Temp --- --- ----- ----1 1 May 752 2 July 853 3 June 764 14 July 895 15 May 706 15 June 80C.Obs Day Month Temp --- --- ----- ----1 1 May 752 15 May 703 3 June 764 15 June 805 2 July 856 14 July 89D.Obs Day Month Temp--- --- ----- ----1 15 May 702 1 May 753 15 June 804 3 June 765 14 July 896 2 July 85Answer: C-------------------------------------28.Given the SAS data set WORK.P2000:Location Pop2000-------- -------Alaska 626931Delaware 783595Vermont 608826Wyoming 493782and the SAS data set WORK.P2008:State Pop2008-------- -------Alaska 686293Delaware 873092Wyoming 532668The following output is desired:Obs State Pop2000 Pop2008 Difference1 Alaska 626931 686293 593622 Delaware 783595 873092 894973 Wyoming 493782 532668 38886 Which SAS program correctly combines the data?A.data compare;merge WORK.P2000(in=_a Location=State)WORK.P2008(in=_b);by State;if _a and _b;Difference=Pop2008-Pop2000;run;B.data compare;merge WORK.P2000(rename=(Location=State))WORK.P2008;by State;if _a and _b;Difference=Pop2008-Pop2000;run;C.data compare;merge WORK.P2000(in=_a rename=(Location=State)) WORK.P2008(in=_b);by State;if _a and _b;Difference=Pop2008-Pop2000;run;D.data compare;merge WORK.P2000(in=_a) (rename=(Location=State)) WORK.P2008(in=_b);by State;if _a and _b;Difference=Pop2008-Pop2000;run;Answer: C-------------------------------------29.The following SAS program is sumbitted:data ;infile 'DATAFILE.TXT';input @1 Company $20. @25 State $2. @;if State=' ' then input @30 Year;else input @30 City Year;input NumEmployees;run;How many raw data records are read during each iteration of the DATA step?A. 1B. 2C. 3D. 4Answer: A-------------------------------------30.You're attempting to read a raw data file and you see the following messages displayed in the SAS Log:NOTE: Invalid data for Salary in line 4 15-23.RULE: ----+----1----+----2----+----3----+----4----+----5--4 120104 F 46#30 11MAY1954 33Employee_Id=120104 employee_gender=F Salary=. birth_date=-2061 _ERROR_=1 _N_=4NOTE: 20 records were read from the infile 'c:\employees.dat'.The minimum record length was 33.The maximum record length was 33.NOTE: The data set WORK.EMPLOYEES has 20 observations and 4 variables. What does it mean?A. A compiler error, triggered by an invalid character for the variable Salary.B. An execution error, triggered by an invalid character for the variable Salary.C. The 1st of potentially many errors, this one occurring on the 4th observation.D. An error on the INPUT statement specification for reading the variable Salary.Answer: B------------------------------------------------------------------31. Given the following raw data records in DATAFILE.TXT:----|----10---|----20---|----30Kim,Basketball,Golf,TennisBill,FootballTracy,Soccer,TrackThe following program is submitted:data WORK.SPORTS_INFO;length Fname Sport1-Sport3 $ 10;infile 'DATAFILE.TXT' dlm=',';input Fname $ Sport1 $ Sport2 $ Sport3 $;run;proc print data=WORK.SPORTS_INFO;run;Which output is correct based on the submitted program?A.Obs Fname Sport1 Sport2 Sport31 Kim Basketball Golf Tennis2 Bill Football3 Tracy Soccer TrackB.Obs Fname Sport1 Sport2 Sport31 Kim Basketball Golf Tennis2 Bill Football Football Football3 Tracy Soccer Track TrackC.Obs Fname Sport1 Sport2 Sport31 Kim Basketball Golf Tennis2 Bill Football Tracy SoccerD.Obs Fname Sport1 Sport2 Sport31 Kim Basketball Golf Tennis2 Bill FootballAnswer: C------------------------------------------------------------------32.Consider the following data step:data WORK.NEW;set WORK.OLD;Count+1;run;The variable Count is created using a sum statement. Which statement regarding this variable is true?A. It is assigned a value 0 when the data step begins execution.B. It is assigned a value of missing when the data step begins execution.C. It is assigned a value 0 at compile time.D. It is assigned a value of missing at compile time.Answer: C------------------------------------------------------------------33.The following SAS program is submitted:data WORK.TEST;set WORK.PILOTS;if Jobcode='Pilot2' then Description='Senior Pilot';else Description='Unknown';run;The value for the variable Jobcode is: PILOT2.What is the value of the variable Description?A. PILOT2B. UnknownC. Senior PilotD. ' ' (missing character value)Answer: B------------------------------------------------------------------34.A user-defined format has been created using the FORMAT procedure.How is it stored?A. in a SAS catalogB. in a memory resident lookup tableC. in a SAS dataset in the WORK libraryD. in a SAS dataset in a permanent SAS data libraryAnswer: AThese formats must be stored in the WORK.FORMATS or SASUSER.FORMATS catalog------------------------------------------------------------------35.given the SAS data set SASDATA.TWO:X Y-- --5 23 15 6The following SAS program is submitted:data SASUSER.ONE SASUSER.TWO OTHER;set SASDATA.TWO;if X eq 5 then output SASUSER.ONE;if Y lt 5 then output SASUSER.TWO;output;run;What is the result?A.data set SASUSER.ONE has 5 observationsdata set SASUSER.TWO has 5 observationsdata set WORK.OTHER has 3 observationsB.data set SASUSER.ONE has 2 observationsdata set SASUSER.TWO has 2 observationsdata set WORK.OTHER has 1 observationsC.data set SASUSER.ONE has 2 observationsdata set SASUSER.TWO has 2 observationsdata set WORK.OTHER has 5 observationsD. No data sets are output. The DATA step fails execution due to syntax errors. Answer: A------------------------------------------------------------------36.Given the contents of the raw data file 'EMPLOYEE.TXT':----+----10---+----20---+----30--Xing 2 19 2004 ACCTBob 5 22 2004 MKTGJorge 3 14 2004 EDUCThe following SAS program is submitted:data WORK.EMPLOYEE;infile 'EMPLOYEE.TXT';input@1 FirstName $@15 StartDate@25 Department $;run;Which SAS informat correctly completes the program?A. date9.B. mmddyy10.C. ddmmyy10.D. mondayyr10.Answer: B-------------------------------------------------------------37.The SAS data set Fed.Banks contains a variable Open_Date which hasbeen assigned a permanent label of "Open Date". Which SAS program temporarily replaces the label "Open Date" with the label "Starting Date" in the output?A.proc print data=SASUSER.HOUSES label;label Open_Date "Starting Date";run;B.proc print data=SASUSER.HOUSES label;label Open_Date="Starting Date";run;C.proc print data=SASUSER.HOUSES;label Open_Date="Starting Date";run;D.proc print data=SASUSER.HOUSES;Open_Date="Starting Date";run;Answer: B------------------------------------------------------------------ 38.Given the SAS data set WORK.ONE:X Y Z- - --1 A 271 A 331 B 452 A 522 B 693 B 704 A 824 C 91The following SAS program is submitted:data WORK.TWO;set WORK.ONE;by X Y;if First.Y;run;proc print data=WORK.TWO noobs;run;Which report is produced?A.X Y Z-- -- --1 B 452 A 522 B 693 B 704 A 824 C 91B.X Y Z-- -- --1 A 271 B 452 A 522 B 693 B 704 A 824 C 91C.X Y Z-- -- --1 A 331 B 452 A 522 B 693 B 704 A 824 C 91D. The PRINT procedure fails because the data set WORK.TWO is not created in the DATA step.Answer: B------------------------------------------------------------------39.The following SAS program is submitted:data WORK.AUTHORS;array Favorites{3} $ 8 ('Shakespeare','Hemingway','McCaffrey');run;What is the value of the second variable in the dataset WORK.AUTHORS?A. HemingwayB. HemingwaC. ' ' (a missing value)D. The program contains errors. No variables are created.Answer: B------------------------------------------------------------------40.The following SAS program is submitted:data WORK.PRODUCTS;Prod=1;do while(Prod LE 6);Prod + 1;end;run;What is the value of the variable Prod in the output data set?A. 6B. 7C. 8D. . (missing numeric)Answer: B------------------------------------------------------------------41.Given the raw data record in the file phone.txt:----|----10---|----20---|----30---|Stevens James SALES 304-923-3721 14The following SAS program is submitted:data WORK.PHONES;infile 'phone.txt';input EmpLName $ EmpFName $ Dept $ Phone $ Extension;<_insert_code_>run;Which SAS statement completes the program and results in a value of "James Stevens" for the variable FullName?A. FullName=CATX(' ',EmpFName,EmpLName);B. FullName=CAT(' ',EmpFName,EmpLName);C. FullName=EmpFName!!EmpLName;D. FullName=EmpFName + EmpLName;Answer: A------------------------------------------------------------------42.The following SAS program is submitted:data WORK.ONE;Text='Australia, US, Denmark';Pos=find(Text,'US','i',5);run;What value will SAS assign to Pos?A. 0B. 1C. 2D. 12Answer: D------------------------------------------------------------------43.Given the SAS data set WORK.ORDERS:WORK.ORDERSorder_id customer shipped-------- ------------ ---------9341 Josh Martin 02FEB20099874 Rachel Lords 14MAR200910233 Takashi Sato 07JUL2009The variable order_id is numeric; customer is character; and shipped is numeric, contains a SAS date value, and is shown with the DATE9. format.A programmer would like to create a new variable, ship_note, that shows a character value with the order_id,shipped date, and customer name.For example, given the first observation ship_note would have the value "Order 9341 shipped on 02FEB2009 to Josh Martin".Which of the following statement will correctly create the value and assign it to ship_note?A. ship_note=catx(' ','Order',order_id,'shippedon',input(shipped,date9.),'to',customer);B. ship_note=catx(' ','Order',order_id,'shippedon',char(shipped,date9.),'to',customer);C. ship_note=catx(' ','Order',order_id,'shippedon',transwrd(shipped,date9.),'to',customer);D. ship_note=catx(' ','Order',order_id,'shippedon',put(shipped,date9.),'to',customer);Answer: D------------------------------------------------------------------44.The following SAS program is submitted:data ONE TWO SASUSER.TWOset SASUSER.ONE;run;Assuming that SASUSER.ONE exists, how many temporary and permanent SAS data sets are created?A. 2 temporary and 1 permanent SAS data sets are createdB. 3 temporary and 2 permanent SAS data sets are createdC. 2 temporary and 2 permanent SAS data sets are createdD. there is an error and no new data sets are createdAnswer: D------------------------------------------------------------------45.The following SAS program is submitted:ods csvall file='c:\test.cvs';proc print data=WORK.ONE;var Name Score Grade;by IdNumber;run;ods csvall close;What is produced as output?A. A file named test.cvs that can only be opened in Excel.B. A text file named test.cvs that can be opened in Excel or in any text editor.C. A text file named test.cvs that can only be opened in a text editor.D. A file named test.cvs that can only be opened by SAS.Answer: B------------------------------------------------------------------46.Given the SAS data set WORK.ONE:Obs Revenue2008 Revenue2009 Revenue2010--- ----------- ----------- -----------1 1.2 1.6 2.0The following SAS program is submitted:。

SAS-base-考试必备-70真题(附答案).docx

SAS-base-考试必备-70真题(附答案).docx

l.The following SAS program is submitted:data WORK.TOTAL;set WORK.SALARY;by Department Gender;if First.<_insert_code_> then Payroll=0;Payroll+W agerate;if Last.<sert_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 DepartmentD.Department GenderAnswer: A2.Given the following raw data records in TEXTFILE.TXT: ——— 10—|—-20—|——30John,FEB, 13,25,14,27,FinalJohn,MAR,26,17,29,11,23,CurrentTina,FEB,15,l & 12,13,FinalTina,MAR,29,14,19,27,20,CurrentThe following output is desired:Name Month Status Weekl Week2 Week3 Week4 ObsWeek51 John FEB Final $13 $25 $14 $27 ■2 John MAR Current $26 $17 $29 $11 $233 Tina FEB Final $15 $18 $12 $13 ■4 Tina MAR Current $29 $14 $19 $27 $20 Which SAS program correctly produces the desired output?A.data WORK.NUMBERS;length Name $ 4 Month $ 3 Status $ 7;infile TEXTFILE.TXT1 dsd;input Name $ Month $;讦Month='FEB' then input Weekl Week2 Week3 Week4 Status $;else 讦Month='MAR‘ then input Weekl Week2 Week3 Week4 Week5 Status $;format Weekl-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 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 Status $ 7;infile ‘TEXTFILE.TXT’ dlm=V;input Name $ Month $ @;if Month=,FEB' then input Weekl Week2 Week3 Week4 Status $;else if Month二'MAR' then i叩ut Weekl Week2 Week3 Week4 Week5 Status $;format Weekl-Week5 dollar6.;run;proc print data=WORK.NUMBERS;run;D.data WORK.NUMBERS;length Name $ 4 Month $ 3 Status $ 7;infile TEXTFILE.TXT1 dsd @;input Name $ Month $;讦Month^'FEB* then input Weekl Week2 Week3 Week4 Status $;else 讦Month二'MAR' then input Weekl Week2 Week3 Week4 Week5 Status $;format Weekl-Week5 dollar6.;run;proc print data=WORK.NUMBERS;run;Answer: C3.The Excel workbook REGIONS.XLS contains the following four worksheets:EASTWESTNORTHSOUTHThe following program is submitted:libname MYXLS Tegions.xls:Which PROC PRINT step correctly displays 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;Answer: D4.The following SAS program is submitted:data WORK.DATE_INFO;DayiOl” ;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・ a missing value due to syntax errorsD. the step will not compile because of the character argument in the mdy function.Answer: A5.Which statement specifies that records 1 through 10 are to be read from the raw data file customentxt?A.infile customer.txt1 1-10;B.input ^ustomer.txt stop@10;C.infile 'customer.txt1 obs=10;D.input ^ustomentxt1 stop=10;Answer: C6.After a SAS program is submitted, the following is written to the SAS log:101data WORK.JANUARY;102set WORK.ALLYEAR(keep=product month nuin_Sold Cost);103讦Month二'Jan' then output WORK.JANUARY;104Sales=Cost * Num_Sold;105keep=Product Sales;22ERROR 22-322: Syntax error, expecting one of the following: !,!!, &, *, **, +,・,,<=, <>,二,>,>=,AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG,NL,NOTIN, OR, A=, |, ||,〜二.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;Answer: D7.Which of the following choices is an unacceptable ODS destination for producing output that can be viewed in Microsoft Excel?A.MSOFFICE2KB.EXCELXPC.CSVALLD.WINXPAnswer: DS.The SAS data set named 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=l then Payroll=0;Payroll4-(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 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.SALARY data set.Answer: C lO.The 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 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 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.Answer: C因为有一个$符号11 .Given the existing SAS program:proc format;value agegrplow-12 =P re-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 generate the following results:Analysis Variable : HeightNAge Obs Minimum Maximum SexMeanF Pre-Teen 3 51.3 59.8 55.8Teen 6 56.5 66.5 63.0 M Pre-Teen 4 57.3 64.8 59.7 Teen 6 62.5 72.0 66.8A.var Height / nobs min max mean maxdec= 1;B.proc means data=SASHELP.CLASS maxdec=l ;C.proc means data=SASHELP.CLASS min max mean maxdec= 1;D.output nobs min max mean maxdec= 1;Answer: C12.The Excel workbook QTR1.XLS contains the following three worksheets:JANFEBMARWhich 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 'qtrl.xls1;D.libname mydata 'qtrl.xls1 WORK.heets=(jan,feb,mar);Answer: A13.The following SAS program is submitted:data WORK.TEST;set WORK.MEASLES(keep=Janpt Febpt Marpt); array Diff{3} Difcount 1 -Difcount3;array Patients{3} Janpt Febpt Marpt;run;What new variables are created?A.Difcount 1, Difcount2 and Difcount3B.Diffl,Diff2and Diff3C.Janpt, Febpt, and MarptD.Patients 1, Patients2 and Patients3Answer: A14.Which 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二'Centnil';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.PILOTS;State=scan(cityState,2,* *);if State=,NE r then description二'Central';run;D.data WORK.TEST / debugger; set WORK.PILOTS;State=scan(cityState,2/ *);if State=,NE, then description二'Central'; run;Answer: c15.Which 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.Answer: D16.The following SAS program is submitted:data WORK.DATE_INFO;X=,04jul2005,d;DayOfMonth=day(x);MonthOfY ear=month(x);Yeai-year(x);run;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.Answer: B17.Given the following data step:data WORK.GEO;infile datalines;input City $20.;if City-Tulsa1 thenState 二OK:Region二'Central:if City二Los Angeles1 thenState=,CA,;Region^Western1;datalines;TulsaLos AngelesBangor■run;After data step execution, what will data set WORK.GEO contain?A.RegionCity StateTulsa OK WesternLos Angeles CA WesternBangor WesternB.City State RegionTulsa OK WesternLos Angeles CA WesternBangorc.City State RegionTulsa OK CentralLos Angeles CA WesternBangor WesternD.City State RegionTulsa OK CentralLos CA WesternBangorAnswer: A18.Which 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 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.Answer: C19.The SAS data set WORK.ONE contains a numeric variable named Num and a character variable named Char:WORK.ONENum Char1233 231 77The following SAS program is submitted:proc print data=WORK.ONEwhere Num二T;run;What is output?A.Num CharB.Num Char1 231 77C.Num Char■ ■■1 233 231 77D.No output is generated.Answer: D20.The data set WORK.REALESTATE has the variable LocalFee with a format of 9. and a variable CountryFee with a format of 7.;The following SAS program is submitted:data WORK.FEE_STRUCTURE;format LocalFee CountryFee percent7.2;set WORK.REALESTAT;LocalFee=LocalFee/l 00;CountryFee 二CountryFee/100;run;What are the formats of the variables LOCALFEE and COUNTRYFEE in the output dataset?A.LocalFee has format of 9. and CountryFee has a format of 7.B.LocalFee has format of 9. and CountryFee has a format of percent7.2C.Both LocalFee and CountryFee have a format of percent7.2D.The data step fails execution; there is no format for LocalFee.Answer: C21.Given the SAS data set WORK.PRODUCTS:Prodld Price ProductType Sales ReturnsK12S 95.50 OUTDOOR 15 2B132S 2.99 CLOTHING 300 10R18KY2 51.99 EQUIPMENT 25 53KL8BY 6.39 OUTDOOR 125 15DY65DW 5.60 OUTDOOR 45 5DGTY23 34.55 EQUIPMENT 67 2The following SAS program is submitted:data WORK.OUTDOOR WORK.CLOTH WORK.EQUIP;set WORK.PRODUCTS;if Sales GT 30;if ProductType EQ 'OUTDOOR' then output WORK.OUTDOOR; else if ProductType EQ 'CLOTHING' then output WORK.CLOTH;else if ProductType EQ 'EQUIPMENT then output WORK.EQUIP;run;How many observations does the WORK.OUTDOOR data set contain?A.1B.2C.3D.6Answer: B22.Which step displays a listing of all the data sets in the WORK library?A.proc contents lib=WORK run;B.proc contents lib=WORK.all;run;C.proc contents data=WORK._all_; run;D.proc contents data=WORK _ALL_; run;Answer: c23.Which is a valid LIBNAME statement?A.libname n_SAS_data_library_location_n;B.sasdata libname H_SAS_data_library_location_M;C.libname sasdata H SAS data library location ”;D.libname sasdata sas H_SAS_data_library_location_n;Answer: C24.Given the following raw data records:・...|—— 10■一|—-20—|- (30)Susan* 12/29/1970* 10Michael**6The following output is desired:Obs employee bdate years1Susan 4015 102Michael . 6Which SAS program correctly reads in the raw data? A.data employees;infile 'file specification' dim- input employee $ bdate : mmddyylO. years;run;B.data employees;infile 'file specification* dsd='*';input employee $ bdate mmddyylO- years;run;c.data employees;infile 'file specification* dim dsd; input employee $ bdate mmddyylO. years; run;D.data employees;infile 'file specification* dim二dsd; input employee $ bdate : mmddyylO. years; run;Answer: D25.Given the following code:proc print data=SASHELP.CLASS(firstobs=5 obs=15);where Sex二M;run;How many observations will be displayed?A.11B.15C.10 or fewerD.11 or fewerAnswer: D26.Which step sorts the observations of a permanent SAS data set by two variables and stores the sorted observations in a temporary SAS data set?A.proc sort out=EMPLOYEES data=EMPSORT;by Lname and Fname;run;B.proc sort data=SASUSER.EMPLOYEES out二EMPSORT;by Lname Fname;run;c.proc sort out=SASUSER.EMPLOYEES data二WORK.EMPSORT;by Lname Fname;run;D.proc sort data=SASUSER.EMPLOYEES out=SASUSER.EMPSORT;by Lname and Fname;run;Answer: B27.Given the SAS data set WORK.TEMPS:Day Month Temp1 May 7515 May 7015 June 803 June 762 July 8514 July 89The following program is submitted:proc sort data二WORK.TEMPS; by descending Month Day;run;proc print data=WORK.TEMPS; run;Which output is correct?A.Obs Day Month Temp1 2 July 852 14 July 893 3 June 764 15 June 805 1 May 756 15 May 7B.Obs Day Month Temp1 1 May 752 2 July 853 3 June 764 14 July 895 15 May 706 15 June 80C.Obs Day Month Temp1 1 May 752 15 May 703 3 June 764 15 June 805 2 July 856 14 July 89D.Obs Day Month Temp1 15 May 702 1 May 75315 June 804 3 June 765 14 July 896 2 July 85 Answer: C28.Given the SAS data set WORK.P2000:Location Pop2000Alaska 626931Delaware 783595Vermont 608826Wyoming 493782and the SAS data set WORK.P200& State Pop2008Alaska 686293Delaware 873092Wyoming 532668The following output is desired:Obs State Pop2000 Pop20081Alaska 626931 6862932Delaware 783595 8730923Wyoming 493782 532668 Which SAS program correctly combines the data?A. Difference593628949738886data compare;merge WORK.P2000(in=_a Location=State) WORK.P2008(in=_b);by State;if _a and _b;Difference二Pop2008・Pop2000;run;B.data compare;merge WORK.P2000(rename=(Location=State)) WORK.P200&by State;if _a and _b;Difference 二Pop2008・Pop2000;run;C・data compare;merge WORK.P2000(in=_a rename=(Location=State)) WORK.P2008(in=_b);by State;if _a and _b;Difference=Pop2008-Pop2000;run;D.data compare;merge WORK.P2000(in=_a) (rename=(Location=State)) WORK.P2008(in=_b);by State;if _a and _b;Difference=Pop2008-Pop2000;run;Answer: C29.The following SAS program is sumbitted:data ;infile DATAFILE.TXT:input @1 Company $20. @25 State $2. @;if State='' then input @30 Year;else input @30 City Year; input NumEmployees;run;How many raw data records are read during each iteration of the DATA step?A.1B.2C.3D.4Answer: A30・YouTe attempting to read a raw data file and you see the following messages displayed in the SAS Log:NOTE: Invalid data for Salary in line 4 15-23.RULE: —+— 1 —+—2—+—3—+—4—+—5■■4120104 F 46#30 11MAY1954 33Employee_Id= 120104 employee_gender=F Salary=. birth_date=-2061 _ERROR_= 1 _N_=4NOTE: 20 records were read from the infile c:\employees.dat\The minimum record length was 33.The maximum record length was 33.NOTE: The data set WORK.EMPLOYEES has 20 observations and 4 variables. What does it mean?A.A compiler error, triggered by an invalid character for the variable Salary.B・ An execution error, triggered by an invalid character for the variable Salary.C.The 1st of potentially many errors, this one occurring on the 4th observation.D.An error on the INPUT statement specification for reading the variable Salary. Answer: B31.Given the following raw data records in DATAFILE.TXT: ——|——10—|——20—|——30Kim,Basketball,Golf,TennisBill,FootballT racy,Soccer,T rackThe following program is submitted:data WORK.SPORTS_INFO; length Fname Sport 1-Sport3 $ 10; infile ‘DATAFILE.TXT dlm=;; input Fname $ Sport 1 $ Sport2 $ Sport3 $;run;proc print data=WORK.SPORTS_INFO;run;Which output is correct based on the submitted program?Obs A.Fname Sport 1 Sport2Sport31 Kim Basketball Golf Tennis2 Bill Football3 Tracy Soccer TrackB.Obs Fname Sport 1 Sport2 Sport31 Kim Basketball Golf Tennis2 Bill Football Football Football3 Tracy Soccer Track TrackC.Obs Fname Sport 1 Sport2 Sport31 Kim Basketball Golf Tennis2 Bill Football Tracy SoccerD.Obs Fname Sport 1 Sport2 Sport31 Kim Basketball Golf Tennis2 Bill FootballAnswer: C32.Consider the following data step:data WORK.NEW;set WORK.OLD;Count+1;run;The variable Count is created using a sum statement. Which statement regarding this variable is true?A.It is assigned a value 0 when the data step begins execution.B.It is assigned a value of missing when the data step begins execution.C.It is assigned a value 0 at compile time.D.It is assigned a value of missing at compile time.Answer: C33.The following SAS program is submitted:data WORK.TEST;set WORK.PILOTS;if Jobcode='Pilot2' then Description二'Senior Pilot'; else Description=,Unknown,;run;The value for the variable Jobcode is: PILOT2.What is the value of the variable Description?A.PILOT2B.UnknownC.Senior PilotD.11 (missing character value)Answer: B34. A user-defined format has been created using the FORMAT procedure.How is it stored?A.in a SAS catalogB.in a memory resident lookup tableC.in a SAS dataset in the WORK libraryD.in a SAS dataset in a permanent SAS data libraryAnswer: AThese formats must be stored in the WORK.FORMATS or SASUSER.FORMATS catalog35.given the SAS data set SASDATA.TWO:X Y5 23 15 6The following SAS program is submitted:data SASUSER.ONE SASUSER.TWO OTHER;set SASDATA.TWO;if X eq 5 then output SASUSER.ONE;if Y It 5 then output SASUSER.TWO; output;run;What is the result?A.data set SASUSER.ONE has 5 observationsdata set SASUSER.TWO has 5 observationsdata set WORK.OTHER has 3 observationsB.data set SASUSER.ONE has 2 observationsdata set SASUSER.TWO has 2 observationsdata set WORK.OTHER has 1 observationsC.data set SASUSER.ONE has 2 observationsdata set SASUSER.TWO has 2 observationsdata set WORK.OTHER has 5 observationsD.No data sets are output. The DATA step fails execution due to syntax errors. Answer: A36.Given the contents of the raw data file EMPLOYEE.TXT*:-—+・—10—+-—20—+-—30■■ Xing2 19 2004 ACCT5 22 2004 MKTG 3 14 2004 EDUCThe following SAS program is submitted:data WORK.EMPLOYEE;infile EMPLOYEE.TXT ;input@ 1 FirstName $@15 StartDate@25 Department $;run;Which SAS infonnat correctly completes the program?A. date9・B. mmddyylO.C. ddmmyylO.D. mondayyrlO.Answer: B37. The SAS data set Fed.Banks contains a variable Open_Date which has been assigned a permanent label of H Open Date”. Which SAS program temporarily replaces the label "Open Date" with the label "Starting Date n in the output?A.proc print data=SASUSER.HOUSES label;label Open_Date ''Starting Date";run;B.proc print data=SASUSER.HOUSES label;label Open_Date= "Starting Date";run;C.proc print data=SASUSER.HOUSES; label Open_Date= "Starting Date";run;D.proc print data=SASUSER.HOUSES;Open_Date=H Starting Date”;run;BobJorgeAnswer: B38.Given the SAS data set WORK.ONE:X Y Z■ ■1 A 271 A 331 B 452 A 522 B 693 B 704 A 824 C 91The following SAS program is submitted: data WORK.TWO;set WORK.ONE;byX Y;if First. Y;run;proc print data=WORK.TWO noobs;run;Which report is produced?A.X Y z1 B 452 A 522 B 693 B 704 A 824 C 91B.X Y Z■ ■1 A 271 B 452 A 522 B 693 B 704 A 824 C 91C・X Y Z1 A 331 B 452 A 522 B 693 B 704 A 824 C 91D. The PRINT procedure fails because the data set WORK.TWO is not created in the DATA step.Answer: B39.The following SAS program is submitted:data WORK.AUTHORS;array Favorites{3} $ 8 ('Shakespeare','Hemingway*,'McCaffrey');run;What is the value of the second variable in the dataset WORK. AUTHORS?A.HemingwayB.HemingwaC.' * (a missing value)D.The program contains enors. No variables are created.Answer: B4O.The following SAS program is submitted: data WORK.PRODUCTS;Prod= 1;do while(Prod LE 6);Prod + 1;end;run;What is the value of the variable Prod in the output data set?A.6B.7C.8D.• (missing numeric)Answer: B41.Given the raw data record in the file phone.txt:—|— ] 0—|—20—|—30—|Stevens James SALES 304-923-3721 14The following SAS program is submitted:data WORK.PHONES;infile ‘phone.txt:input EmpLName $ EmpFName $ Dept $ Phone $ Extension; <_insert_code_> run;Which SAS statement completes the program and results in a value of n James Stevens11 for the variable FullName?A.FullName=CATX('EmpFName,EmpLName);B.FullName=CAT('EmpFName,EmpLName);C.FullName=EmpFName! !EmpLName;D.FullName=EmpFName + EmpLName;Answer: A42.The following SAS program is submitted: data WORK.ONE;Text^^ustralia, US, Denmark1;Pos=find(Text;US';i\5);run;What value will SAS assign to Pos?A.0B.1C.2D.12Answer: D43.Given the SAS data set WORK.ORDERS:WORK.ORDERSorder_id customer shipped9341 Josh Martin 02FEB20099874 Rachel Lords 14MAR200910233 Takashi Sato (UJUL2009The variable order_id is numeric; customer is character; and shipped is numeric, contains a SAS date value, and is shown with the DATE9. format.A programmer would like to create a new variable, ship_note, that shows a character value with the order_id,shipped date, and customer name.For example, given the first observation ship_note would have the value n Order 9341 shipped on 02FEB2009 to Josh Martin**.Which of the following statement will correctly create the value and assign it toship_note?A.ship_note二catx(‘ \r Order\order_id/shippedon\input(shipped,date9.)/to\customer);B.ship_note=catx(, 7Order\order_id/shipped on\char(shipped,date9.)/to\customer);C.ship_note=catxC f/Order\order_id/shippedon\transwrd(shipped,date9.)/to\customer);D.ship_note=catx(, \f Order\order_id/shipped on\put(shipped,date9.)/to\customer);Answer: D44.The following SAS program is submitted:data ONE TWO SASUSER.TWOset SASUSER.ONE;run;Assuming that SASUSER.ONE exists, how many temporary and permanent SAS data sets are created?A.2 temporary and 1 permanent SAS data sets are createdB.3 temporary and 2 permanent SAS data sets are createdC.2 temporary and 2 permanent SAS data sets are createdD.there is an error and no new data sets are createdAnswer: D45.The following SAS program is submitted:ods csvall file—c:\test.cvs:proc print data=WORK.ONE;var Name Score Grade;by IdNumber;run;ods csvall close;What is produced as output?A.A file named test.cvs that can only be opened in Excel.B.A text file named test.cvs that can be opened in Excel or in any text editor.C.A text file named test.cvs that can only be opened in a text editor.D.A file named test.cvs that can only be opened by SAS.Answer: C46.Given the SAS data set WORK.ONE:Obs Revenue2008 Revenue2009 Revenue20101 1.2 1.6 2.0The following SAS program is submitted:data WORK.TWO;set WORK.ONE; Total=mean(of Rev:);run;What value will SAS assign to Total?A.3B.1.6C.4.8D.The program fails to execute due to errors.Answer: B47.The following output is created by the FREQUENCY procedure:The FREQ ProcedureTable of region by productregion productFrequencylPercent |Row Pct |Col Pct |com |cotton |oranges | TotalEAST | 2| 1| 1 | 4| 22.221 11.11 | 11.11 | 44.44| 50.001 25.001 25.001| 50.001 33.33 1 50.001SOUTH 1 2121 11 5| 22.221 22.22 | 11.11 | 55.56| 40.001 40.00 | 20.00 || 50.001 66.67 | 50.00 |—4"————————"FTotal 4 3 2 944.44 33.33 22.22 100.00Which TABLES option(s) would be used to eliminate the row and column counts and just see the frequencies and percents?A. norowcount nocolcountB. freq percentC. norow nocolD. nocountsAnswer: C48. The following SAS program is submitted:data WORK.TEST; drop City; infile datalines; inputName$ 1-14/Address $ 1-14 /City$ 1-12;if City 二New York * then input @1 State $2.; else input;datalines;Joe Conley123 Main St.JanesvilleWIJane Ngyuen555 Alpha Ave.New YorkNYJennifer Jason666 Mt. DiabloEurekaCA■What will the data set WORK.TEST contain?B.Name Address City StateName AddressState Joe Conley Jane Ngyuen Jennifer Jason 123 Main St.555 Alpha Ave.666 Mt. DiabloNYJoe Conley Jane Ngyuen Jennifer Jason123 Main St.555 Alpha Ave.666 Mt. DiabloJanesvilleNew YorkEurekaNYC・NameAddress StateJane Ngyuen 555 Alpha Ave. NYD. O observations,there is a syntax error in the data step.Answer: A49.The following SAS program is submitted:data WORK.TOTALSALES(keep=MonthSales{ 12});set WORK.MONTHLYSALES(keep=Year Product Sales);array MonthSales{ 12};do i=l to 12;MonthSales {i }=Sales;end;drop i;run;The program fails execution due to syntax errors.What is the cause of the syntax error?A.An array cannot be referenced on a keep= data set option.B.The keep二data set option should be (keep二MonthSales*).C.The keep= data set option should be the statement KEEP MonthSales {12 }•D.The variable MonthSales does not exist.Answer: A5O.Given the SAS data set WORK.ONE:Id Chari111 A158 B329 C644 Dand the SAS data set WORK.TWO:Id Char2■■■111 E538 F644 GThe following program is submitted:data WORK.BOTH;set WORK.ONE WORK.TWO;by Id;run;What is the first observation in SAS data set WORK.BOTH?A.Id Chari Char2■■■ ■■■■ ■■■■111 AB.Id Chari Char2■■■111 EC・Id Chari Char2■■■111 A ED.Id Chari Char2■■■644 D GAnswer: A 5 l.The following program is submitted:proc contents data=_all_;run;Which statement best describes the output from the submitted program?A.The output contains only a list of the SAS data sets that are contained in the WORK library.。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

1. A raw data file is listedbelow.The following program issubmitted using this file asinput:data work.family;infile 'file-specification';<insert INPUTstatement here>run;Which INPUT statementcorrectly reads the values forthe variable Birthdate asSAS date values?a.input relation$ first_name$ birthdate date9.;b.input relation$ first_name$ birthdatemmddyy8.;c.input relation$ first_name$ birthdate :date9.;d.input relation$ first_name$ birthdate :mmddyy8.;Correct answer: dAn informat is used to translate the calendar date to a SAS datevalue. The date values are in the form of two-digit values formonth-day-year, so the MMDDYY8. informat must be used.When using an informat with list input, the colon-formatmodifier is required to correctly associate the informat with thevariable name.You can learn about•informats in Reading Date and Time Values•the colon-format modifier in Reading Free-FormatData.2. A raw data file is listed below.1---+----10---+----20---+---Jose,47,210Sue,,108The following SAS program is submitted using the raw data fileabove as input:data employeestats;<insert INFILE statement here>input name $ age weight;run;The following output is desired:name age weightJose47210Sue.108Which of the following INFILE statements completes theprogram and accesses the data correctly?a.infile 'file-specification' pad;b.infile 'file-specification' dsd;c.infile 'file-specification' dlm=',';d.infile 'file-specification' missover;Correct answer: bThe PAD option specifies that SAS pad variable length recordswith blanks. The MISSOVER option prevents SAS fromreading past the end of the line when reading free formatteddata. The DLM= option specifies the comma as the delimiter;however, consecutive delimiters are treated as one by default.The DSD option correctly reads the data with commas asdelimiters and two consecutive commas indicating a missingvalue like those in this raw data file.You can learn about•the PAD option in Reading Raw Data in Fixed Fields•the MISSOVER option in Creating MultipleObservations from a Single Record•the DLM= option and the DSD option in Reading Free-Format Data.3. The following program is submitted:data numrecords;infile cards dlm=',';input agent1 $ agent2 $ agent3 $;cards;jones,,brownjones,spencer,brown;run;What is the value for the variable named Agent2 in the secondobservation?a.Brownb.Spencerc.' ' (missing character value)d.There is no value because only one observation iscreated.Correct answer: dThe CARDS statement enables you to read instream data. Anynumber of consecutive commas are considered to be a singledelimiter as a result of the DLM= option, and the length of eachvariable defaults to 8 bytes. Therefore, the values jones,brownjon, and spencer are assigned to Agent1, Agent2, andAgent3, respectively, for the first observation. The rest of thedata on the record is not read by the INPUT statement and is notoutput to the data set.You can learn about•the CARDS statement in Creating SAS Data Sets fromRaw Data•the default length of variables in Reading Free-FormatData.4. A raw data file is listed below.1---+----10---+----20---+----30---+----40---+----50TWOSTORY 1040 2 1SANDERS ROAD $55,850CONDO 2150 4 2.5JEANS AVENUE $127,150The following program is submitted using this file as input:data work.houses;infile 'file-specification';<insert INPUT statement here>run;Which one of the following INPUT statements reads the rawdata file correctly?a.input @1 style $8.+1 sqfeet 4.+1 bedrooms 1.@20 baths 3.street 16.@40 price dollar8;b.input @1 style $8+1 sqfeet 4.+1 bedrooms 1.@20 baths 3.street $16@40 price dollar8.;c.input @1 style $8.+1 sqfeet 4.+1 bedrooms 1.@20 baths 3.street $16.@40 price dollar8.;d.input @1 style $8.+1 sqfeet 4.+1 bedrooms 1.@20 baths 3street 16.@40 price dollar8.;Correct answer: cFormatted input requires periods as part of the informat name.The period is missing from the variables Style and Street inAnswer b, the variable Baths in Answer d, and the variablePrice in Answer a (which is also missing a dollar sign to readthe variable Street as a character value).You can learn about formatted input and informats in ReadingRaw Data in Fixed Fields.5. The following SAS program is submitted at the start of a newSAS session:libname sasdata 'SAS-data-library';data sasdata.sales;set sasdata.salesdata;profit=expenses-revenues;run;proc print data=sales;run;The SAS data set Sasdata.Salesdata has ten observations.Which one of the following explains why a report fails togenerate?a.The DATA step fails execution.b.The SAS data set Sales does not exist.c.The SAS data set Sales has no observations.d.The PRINT procedure contains a syntax error.Correct answer: bThe DATA step creates a permanent SAS data set,Sasdata.Salesdata. The PRINT procedure is printing atemporary SAS data set, Sales, that is stored in the Worklibrary. At the beginning of the SAS session, Work.Sales doesnot exist.You can learn about•creating permanent data sets with the DATA step inCreating SAS Data Sets from Raw Data•temporary data sets in Basic Concepts.6. Which action assigns a reference named SALES to a permanentSAS data library?a.Issuing the command:libref SALES 'SAS-data-library'b.Issuing the command:libname SALES 'SAS-data-library'c.Submitting the statement:libref SALES 'SAS-data-library';d.Submitting the statement:libname SALES 'SAS-data-library';Correct answer: dThe LIBNAME statement assigns a reference known as a librefto a permanent SAS data library. The LIBNAME commandopens the LIBNAME window.You can learn about the LIBNAME statement in ReferencingFiles and Setting Options.7. The following SAS program is submitted:data newstaff;set staff;<insert WHERE statement here>run;Which one of the following WHERE statements completes theprogram and selects only observations with a Hire_date ofFebruary 23, 2000?a.where hire_date='23feb2000'd;b.where hire_date='23feb2000';c.where hire_date='02/23/2000'd;d.where hire_date='02/23/2000';Correct answer: aA SAS date constant must take the form of one- or two-digitday, three-digit month, and two- or four-digit year, enclosed inquotation marks and followed by a d ('ddmmmyy<yy>'d).You can learn about SAS date constants in Creating SAS DataSets from Raw Data.8. Which one of the following SAS date formats displays the SASdate value for January 16, 2002 in the form of 16/01/2002?a.DATE10.b.DDMMYY10.c.WEEKDATE10.d.DDMMYYYY10.Correct answer: bThe requested output is in day-month-year order and is 10 byteslong, so DDMMYY10. is the correct format. AlthoughWEEKDATE10. is a valid SAS format, it does not display theSAS date value as shown in the question above.DDMMYYYY10. is not a valid SAS date format, and theDATE w. format cannot accept a length of 10.You can learn about•the DDMMYY10. format in Creating List Reports•the WEEKDATE10. format in Reading Date and TimeValues.9. Which one of the following displays the contents of an externalfile from within a SAS session?a.the LIST procedureb.the PRINT procedurec.the FSLIST procedured.the VIEWTABLE windowCorrect answer: cThe PRINT procedure and VIEWTABLE window display thevalues in SAS data sets. The FSLIST procedure displays thevalues in external files. There is no LIST procedure in SAS.You can learn about•the PRINT procedure in Creating List Reports•the VIEWTABLE window in Referencing Files andSetting Options.10. The SAS data set Sashelp.Prdsale contains the variablesRegion and Salary with 4 observations per Region.Sashelp.Prdsale is sorted primarily by Region and withinRegion by Salary in descending order.The following program is submitted:data one;set sashelp.prdsale;retain temp;by region descending salary;if first.region thendo;temp=salary;output;end;if last.region thendo;range=salary-temp;output;end;run;For each region, what is the number of observation(s) written tothe output data set?a.0b.1c. 2d.4Correct answer: cThe expression first.region is true once for each regiongroup. The expression last.region is true once for each regiongroup. Therefore, each OUTPUT statement executes once for atotal of 2 observations in the output data set.You can learn about the FIRST.variable expression and theOUTPUT statement in Reading SAS Data Sets.11. The following SAS program is submitted:proc contents data=sasuser.houses;run;The exhibit below contains partial output produced by theCONTENTS procedure.Data Set Name SASUSER.HOUSES Observations15Member Type DATA Variables6Engine V9Indexes0Created Tuesday, April 22,2003 03:09:25 PMObservationLength56Last Modified Tuesday, April 22,2003 03:09:25 PMDeletedObservationsProtection Compressed NO Data Set Type Sorted NOLabel Residential housing for saleDataRepresentationWINDOWS_32Encoding wlatin1 Western (Windows)Which of the following describes the Sasuser.Houses data set?a.The data set is sorted but not indexed.b.The data set is both sorted and indexed.c.The data set is not sorted but is indexed.d.The data set is neither sorted nor indexed.Correct answer: dThe exhibit above shows partial output from the CONTENTSprocedure, In the top right-hand column of the output, you seethat Indexes has a value of 0, which indicates that no indexesexist for this data set. Also, Sorted has a value of NO, whichindicates that the data is not sorted.You can learn about the CONTENTS procedure in ReferencingFiles and Setting Options.12. The following SAS program is submitted:proc sort data=work.test;by fname descending salary;run;Which one of the following represents how the observations aresorted?a.The data set Work.Test is stored in ascending order byboth Fname and Salary values.b.The data set Work.Test is stored in descending order byboth Fname and Salary values.c.The data set Work.Test is stored in descending order byFname and ascending order by Salary values.d.The data set Work.Test is stored in ascending order byFname and in descending order by Salary values.Correct answer: dThe DESCENDING keyword is placed before the variable nameit modifies in the BY statement, so the correct description is indescending order by Salary value within ascending Fnamevalues.You can learn about the SORT procedure and theDESCENDING keyword in Creating List Reports.13. The following SAS program is submitted:data names;title='EDU';if title='EDU' thenDivision='Education';else if title='HR' thenDivision='Human Resources';else Division='Unknown';run;Which one of the following represents the value of the variableDivision in the output data set?catiocationc.Human Red.Human ResourcesCorrect answer: bThe length of the variable Division is set to 9 when the DATAstep compiles. Since the value of the variable Title is EDU, thefirst IF condition is true; therefore, the value of the variableDivision is Education.You can learn about•the length of a variable in Understanding DATA StepProcessing•IF-THEN statements in Creating and ManagingVariables.14. Which one of the following SAS programs creates a variablenamed City with a value of Chicago?a.data work.airports;AirportCode='ord';if AirportCode='ORD' City='Chicago';run;b.data work.airports;AirportCode='ORD';if AirportCode='ORD' City='Chicago';run;c.data work.airports;AirportCode='ORD';if AirportCode='ORD' then City='Chicago';run;d.data work.airports;AirportCode='ORD';if AirportCode='ORD';then City='Chicago';run;Correct answer: cThe correct syntax for an IF-THEN statement is: IF expressionTHEN statement;In this example, the variable City is assigned a value ofChicago only if the expression AirportCode='ORD' is true.You can learn about IF-THEN statements in Creating andManaging Variables.15. The following SAS program is submitted:data work.building;code='DAL523';code='SANFRAN604';code='HOUS731';length code $ 20;run;Which one of the following is the length of the code variable?a.6b.7c.10d.20Correct answer: aThe DATA step first goes through a compilation phase, then anexecution phase. The length of a variable is set during thecompilation phase and is based on the first time the variable isencountered. In this case, the variable code is set to the lengthof the text string DAL523 which is 6 characters long. The nextassignment statements are ignored during compilation. TheLENGTH statement is also ignored since the length has alreadybeen established, but a note will be written to the log.You can learn about•the compilation phase of the DATA step inUnderstanding DATA Step Processing•the LENGTH statement in Creating and ManagingVariables.16. Which of the following statements creates a numeric variablenamed IDnumber with a value of 4198?a.IDnumber=4198;b.IDnumber='4198';c.length IDnumber=8;d.length IDnumber $ 8;Correct answer: aThe first reference to the SAS variable in the DATA step setsthe name, type, and length of the variable in the program datavector (PDV) and in the output SAS data set. The assignmentstatement IDnumber=4198; is the first reference and creates anumeric variable named IDnumber with a default storage lengthof 8 bytes.You can learn about•creating variables in the DATA step in UnderstandingDATA Step Processing•numeric variables in Basic Concepts.17. The following program is submitted:data fltaten;input jobcode $ salary name $;cards;FLAT1 70000 BobFLAT2 60000 JoeFLAT3 30000 Ann;run;data desc;set fltaten;if salary>60000 then description='Over 60';else description='Under 60';run;What is value of the variable named description when thevalue for salary is 30000?a.Under 6b.Under 60c.Over 60d.' ' (missing character value)Correct answer: aThe variable description is being created by the IF-THEN/ELSE statement during compilation. The first occurrenceof the variable description is on the IF statement, and since itis assigned the value Over 60, the length of the variable is 7.Therefore, for the salary value of 30000, description has thevalue of Under 6 (the 0 is truncated.)You can learn about•the compilation phase of the DATA step inUnderstanding DATA Step Processing•IF-THEN/ELSE statements in Creating and ManagingVariables.18. A raw data file is listed below.1---+----10---+----20---+---102320The following program is submitted:data all_sales;infile 'file-specification';input receipts;<insert statement(s) here>run;Which statement(s) complete(s) the program and produce(s) arunning total of the Receipts variable?a.total+receipts;b.total 0;sum total;c.total=total+receipts;d.total=sum(total,receipts);Correct answer: aThe SUM function and the assignment statement do not retainvalues across iterations of the DATA step. The sum statementtotal+receipts; initializes total to 0, ignores missing valuesof receipt, retains the value of total from one iteration to thenext, and adds the value of receipts to total.You can learn about the sum statement in Creating andManaging Variables.19. A raw data file is listed below.1---+----10---+----20---+---1901 21905 11910 61925 11941 1The following SAS program is submitted and references the rawdata file above:data money;infile 'file-specification';input year quantity;total=total+quantity;What is the value of total when the data step finishesexecuting?a.0b.1c.11d. . (missing numeric value)Correct answer: dThe variable Total is assigned a missing value during thecompilation phase of the DATA step. When the first record isread in, SAS processes: total=.+2; which results in a missingvalue. Therefore the variable Total remains missing for allobservations.You can learn about•the compilation phase of the DATA step inUnderstanding DATA Step Processing•using missing values with arithmetic operators inCreating SAS Data Sets from Raw Data.20. The following program is submitted:data test;average=mean(6,4,.,2);run;What is the value of average?a.0b.3c.4d. . (missing numeric value)Correct answer: cThe MEAN function adds all of the non-missing values anddivides by the number of non-missing values. In this case, 6 + 4+ 2 divided by 3 is 4.You can learn about the MEAN function in Transforming Datawith SAS Functions.21. The following SAS program is submitted:data work.AreaCodes;Phonenumber=3125551212;Code='('!!substr(Phonenumber,1,3)!!')';run;Which one of the following is the value of the variable Code inthe output data set?a.( 3)b.(312)c.3d.312Correct answer: aAn automatic data conversion is performed whenever a numericvariable is used where SAS expects a character value. Thenumeric variable is written with the BEST12. format and theresulting character value is right-aligned when the conversionoccurs. In this example, the value of Phonenumber is convertedto character and right-aligned before the SUBSTR function isperformed. Since there are only 10 digits in the value ofPhonenumber, the right-aligned value begins with two blanks.Therefore the SUBSTR function picks up two blanks and a 3,and uses the BEST12. format to assign that value to Code. Then,the parentheses are concatenated before and after the two blanksand a 3.You can learn about automatic data conversion and theSUBSTR function in Transforming Data with SAS Functions.22. The following SAS program is submitted:data work.inventory;products=7;do until (products gt 6);products+1;end;run;Which one of the following is the value of the variableproducts in the output data set?a.5b.6c.7d.8Correct answer: dA DO UNTIL loop always executes at least once because thecondition is not evaluated until the bottom of the loop. In theSAS program above, the value of Products is incremented from7 to 8 on the first iteration of the DO UNTIL loop, before thecondition is checked. Therefore the value of Products is 8.You can learn about DO UNTIL loops in Generating Datawith DO Loops.23. The following program is submitted:data work.test;set work.staff (keep=salary1 salary2 salary3);<insert ARRAY statement here>run;Which ARRAY statement completes the program and createsnew variables?a.array salary{3};b.array new_salary{3};c.array salary{3} salary1-salary3;d.array new_salary{3} salary1-salary3;Correct answer: bAlthough each of the ARRAY statements listed above is a validstatement, only Answer B creates new variables namednew_salary1, new_salary2 and new_salary3. Answer C andAnswer D both create an array that groups the existing data setvariables salary1, salary2, and salary3. Since the array inAnswer A is named salary, it also uses the existing data setvariables.You can learn about creating new variables in an ARRAYstatement in Processing Variables with Arrays.24. Which of the following permanently associates a format with avariable?a.the FORMAT procedureb.a FORMAT statement in a DATA stepc.an INPUT function with format modifiersd.an INPUT statement with formatted style inputCorrect answer: bTo permanently associate a format with a variable, you use theFORMAT statement in a DATA step. You can use theFORMAT procedure to create a user-defined format. You usethe INPUT function to convert character data values to numericvalues with an informat. You use the INPUT statement to readdata into a data set with an informat.You can learn about•permanently assigning a format to a variable in Creatingand Managing Variables•the FORMAT statement in Creating List Reports•the FORMAT procedure in Creating and ApplyingUser-Defined Formats•the INPUT function in Transforming Data with SASFunctions•the INPUT statement in Reading Raw Data in FixedFields.25. The following report is generated:Which of the following steps created the report?a.proc freq data=sasuser.houses;tables style price /nocum;format price dollar10.;label style="Style of homes"price="Asking price";run;b.proc print data=sasuser.houses;class style;var price;table style,n price*mean*f=dollar10.;label style="Style of homes"price="Asking price";run;c.proc means data=sasuser.houses n mean;class style;var price;format price dollar10.;label style="Style of homes"price="Asking price";run;d.proc report data=sasuser.houses nowd headline;column style n price;define style / group "Style of homes";define price / mean format=dollar8."Asking price";run;Correct answer: dThe FREQ procedure cannot create the average asking price.The CLASS statement and the VAR statement are not valid foruse with the PRINT procedure. The MEANS procedure outputwould have both the N statistic and the N Obs statistic since aCLASS statement is used. The REPORT procedure producedYou can learn about•the FREQ procedure in Producing DescriptiveStatistics•the PRINT procedure in Creating List Reports•the MEANS procedure in Producing DescriptiveStatistics•the REPORT procedure in Creating Enhanced List andSummary Reports.26. A SAS report currently flows over two pages because it is toolong to fit within the specified display dimension. Which one ofthe following actions would change the display dimension sothat the report fits on one page?a.Increase the value of the LINENO option.b.Decrease the value of the PAGENO option.c.Decrease the value of the LINESIZE option.d.Increase the value of the PAGESIZE option.Correct answer: dThe PAGESIZE= SAS system option controls the number oflines that compose a page of SAS procedure output. Byincreasing the number of lines available per page, the reportmight fit on one page.You can learn about the PAGESIZE= option in ReferencingFiles and Setting Options.27. Which one of the following SAS REPORT procedure optionscontrols how column headings are displayed over multiplelines?a.SPACE=BEL=d.BREAK=Correct answer: bThe SPLIT= option specifies how to split column headings. TheSPACE=, LABEL= and BREAK= options are not valid optionsin PROC REPORT.You can learn about the SPLIT= option for the REPORTprocedure in Creating Enhanced List and Summary Reports.28. The following SAS program is submitted:ods html file='newfile.html';proc print data=sasuser.houses;run;proc means data=sasuser.houses;run;proc freq data=sasuser.shoes;run;ods html close;proc print data=sasuser.shoes;run;How many HTML files are created?a.1b.2c. 3d.4Correct answer: aBy default, one HTML file is created for each FILE= option orBODY= option in the ODS HTML statement. The ODS HTMLCLOSE statement closes the open HTML file and ends theoutput capture. The Newfile.html file contains the output fromthe PRINT, MEANS, and FREQ procedures.You can learn about the ODS HTML statement in ProducingHTML Output.29. A frequency report of the variable Jobcode in the Work.Actorsdata set is listed below.Jobcode Frequency Percent CumulativeFrequencyCumulativePercentActor I233.33233.33 Actor II233.33466.67 Actor III233.336100.00Frequency Missing = 1The following SAS program is submitted:data work.joblevels;set work.actors;if jobcode in ('Actor I', 'Actor II') thenjoblevel='Beginner';if jobcode='Actor III' thenjoblevel='Advanced';else joblevel='Unknown';run;Which of the following represents the possible values for the variable joblevel in the Work.Joblevels data set?a.Advanced and Unknown onlyb.Beginner and Advanced onlyc.Beginner, Advanced, and Unknownd.' ' (missing character value)Correct answer: aThe DATA step will continue to process those observations that satisfy the condition in the first IF statement Although Joblevel might be set to Beginner for one or more observations, the condition on the second IF statement willevaluate as false, and the ELSE statement will execute and overwrite the value of Joblevel as Unknown.You can learn about•the IF statement in Creating SAS Data Sets from RawData•the ELSE statement in Creating and ManagingVariables.30. The descriptor and data portions of the Work.Salaries data setare shown below.Variable Type Len Posname Char80salary Char816status Char88name status salaryLiz S15,600Herman S26,700Marty S35,000The following SAS program is submitted:proc print data=work.salaries;where salary<20000;run;What is displayed in the SAS log after the program is executed?a.A NOTE indicating that 1 observation is read.b.A NOTE indicating that 0 observations were read.c.A WARNING indicating that character values have beenconverted to numeric values.d.An ERROR indicating that the WHERE clause operatorrequires compatible variables.Correct answer: dSalary is defined as a character variable. Therefore, the valuein the WHERE statement must be the character value 20,000enclosed in quotation marks.You can learn about the WHERE statement in Creating ListReports.31. Which of the following statements is true when SAS encountersa syntax error in a DATA step?a.The SAS log contains an explanation of the error.b.The DATA step continues to execute and the resultingdata set is complete.c.The DATA step stops executing at the point of the errorand the resulting data set contains observations up to thatpoint.d.A note appears in the SAS log indicating that theincorrect statement was saved to a SAS data set forfurther examination.Correct answer: aSAS scans the DATA step for syntax errors during thecompilation phase. If there are syntax errors, those errors getwritten to the log. Most syntax errors prevent further processingof the DATA step.You can learn about how SAS handles syntax errors in theDATA step in Understanding DATA Step Processing.32. Which TITLE statement would display JANE'S DOG as the textof the title?a.title "JANE"S DOG";b.title 'JANE"S DOG';c.title "JANE'S DOG";d.title 'JANE' ' 'S DOG';Correct answer: c。

相关文档
最新文档