SAS Base认证考试 真题+答案详解
SAS Base 50题 带解释【终极版】
SAS 认证考试样题SAS 中文论坛网站1.A raw data file is listed below.1---+----10---+----20---+---son Frank 01/31/89daughter June 12-25-87brother Samuel 01/17/51The following program is submitted using this file as input:data work.family;infile 'file-specification';<insert INPUT statement here >run;Which INPUT statement correctly reads the values for the variable Birthdate as SAS date values?a. i nput relation $ first_name $ birthdate date9.;b.i nput relation $ first_name $ birthdate mmddyy8.; c.i nput relation $ first_name $ birthdate : date9.; d.i nput relation $ first_name $ birthdate : mmddyy8.; Correct answer: dAn informat is used to translate the calendar date to a SAS date value. The date values are in the form of two-digit values for month-day-year, so the MMDDYY8. informat must be used. When using an informat with list input, the colon-format modifier is required to correctly associate the informat with the variable name.You can learn about•informats in Reading Date and Time Values • the colon-format modifier in Reading Free-Format Data .2.A raw data file is listed below.1---+----10---+----20---+---Jose,47,210Sue,,108The following SAS program is submitted using the raw data file above as input:data employeestats;<insert INFILE statement here>input name $ age weight;run;The following output is desired:name age weight Jose 47 210 Sue . 108Which of the following INFILE statements completes the program and accesses the data correctly?a. infile 'file-specification ' pad;b. infile 'file-specification' dsd;SAS 认证考试样题SAS 中文论坛网站c. infile 'file-specification ' dlm=',';d. infile 'file-specification ' missover;Correct answer: bThe PAD option specifies that SAS pad variable length records with blanks. The MISSOVER option prevents SAS from reading past the end of the line when reading free formatted data. 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 as delimiters and two consecutive commas indicating a missing value 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 Multiple Observations from a SingleRecord• 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 second observation?a.brown b.spencer c.' ' (missing character value) d. There is no value because only one observation is created.Correct answer: dThe CARDS statement enables you to read instream data. Any number of consecutive commas are considered to be a single delimiter as a result of the DLM= option, and the length of each variable defaults to 8 bytes. Therefore, the values jones , brownjon , and spencer are assigned to Agent1, Agent2, and Agent3, respectively, for the firstobservation. The rest of the data on the record is not read by the INPUT statement and is not output to the data set.You can learn about•the CARDS statement in Creating SAS Data Sets from Raw Data • the default length of variables in Reading Free-Format Data .SAS认证考试样题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 raw data 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 in Answer b, the variable Baths in Answer d, and the variable Price in Answer a (which is also missing a dollar sign to read the variable Street as a character value).You can learn about formatted input and informats in Reading Raw Data in Fixed Fields.5. The following SAS program is submitted at the start of a new SAS session:libname sasdata 'SAS-data-library';data sasdata.sales;set sasdata.salesdata;profit=expenses-revenues;run;SAS中文论坛网站SAS 认证考试样题SAS 中文论坛网站proc print data=sales;run;The SAS data set Sasdata.Salesdata has ten observations. Which one of the following explains why a report fails to generate?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 PRINTprocedure is printing a temporary SAS data set, Sales , that is stored in the Work library. At the beginning of the SAS session, Work.Sales does not exist.You can learn about•creating permanent data sets with the DATA step in Creating SAS Data Setsfrom Raw Data• temporary data sets in Basic Concepts . 6. Which action assigns a reference named SALES to a permanent SAS 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 libref to a permanent SAS data library. The LIBNAME command opens the LIBNAME window.You can learn about the LIBNAME statement in Referencing Files 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 the program and selects only observations with a Hire_date of February 23, 2000?a. where hire_date='23feb2000'd;b. where hire_date='23feb2000';c. where hire_date='02/23/2000'd;SAS 认证考试样题SAS 中文论坛网站d. where hire_date='02/23/2000';Correct answer: aA SAS date constant must take the form of one- or two-digit day, three-digit month, and two- or four-digit year, enclosed in quotation marks and followed by a d('ddmmmyy<yy>'d ).You can learn about SAS date constants in Creating SAS Data Sets from Raw Data .8. Which one of the following SAS date formats displays the SAS date 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 bytes long, so DDMMYY10. is the correct format. Although WEEKDATE10. is a valid SAS format, it does notdisplay the SAS date value as shown in the question above. DDMMYYYY10. is not a valid SAS date format, and the DATE 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 Time Values .9. Which one of the following displays the contents of an external file 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 the values in SAS data sets. The FSLIST procedure displays the values in external files. There is no LIST procedure in SAS.You can learn about• the PRINT procedure in Creating List ReportsSAS 认证考试样题SAS 中文论坛网站• the VIEWTABLE window in Referencing Files and Setting Options .10. The SAS data set Sashelp.Prdsale contains the variables Region and Salary with 4 observations per Region . Sashelp.Prdsale is sorted primarily by Region and within Region 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 to the output data set? a. 0b. 1c. 2d. 4Correct answer: cThe expression first.region is true once for each region group. The expression last.region is true once for each region group. Therefore, each OUTPUT statement executes once for a total of 2 observations in the output data set.You can learn about the FIRST.variable expression and the OUTPUT 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 the CONTENTS procedure. Data Set NameSASUSER.HOUSES Observations 15 Member TypeDATA Variables 6 EngineV9 Indexes 0 CreatedTuesday, April 22, 2003 03:09:25 PMObservation Length 56 Last ModifiedTuesday, April 22, 2003 03:09:25 PMDeleted Observations0 Protection CompressedNOSAS认证考试样题Data Set Type Sorted NOLabel Residential housingfor saleData Representation WINDOWS_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 CONTENTS procedure, In the top right-hand column of the output, you see that Indexes has a value of 0, which indicates that no indexes exist for this data set. Also, Sorted has a value of NO, which indicates that the data is not sorted.You can learn about the CONTENTS procedure in Referencing Files 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 are sorted?a. The data set Work.Test is stored in ascending order by both Fname and Salary values.b. The data set Work.Test is stored in descending order by both Fname and Salary values.c. The data set Work.Test is stored in descending order by Fname and ascending order by Salary values.d. The data set Work.Test is stored in ascending order by Fname and in descending order by Salary values.Correct answer: dThe DESCENDING keyword is placed before the variable name it modifies in the BY statement, so the correct description is in descending order by Salary value within ascending Fname values.You can learn about the SORT procedure and the DESCENDING keyword in Creating List Reports.13.The following SAS program is submitted:data names;SAS中文论坛网站SAS 认证考试样题SAS 中文论坛网站title='EDU';if title='EDU' thenelse if title='HR' thenDivision='Human Resources';else Division='Unknown';run;Which one of the following represents the value of the variable Division in the output data set?a. Educatiob. Educationc. Human Red. Human ResourcesCorrect answer: bThe length of the variable Division is set to 9 when the DATA step compiles. Since the value of the variable Title is EDU , the first IF condition is true; therefore, the value of the variable Division is Education .You can learn about•the length of a variable in Understanding DATA Step Processing • IF-THEN statements in Creating and Managing Variables .14.Which one of the following SAS programs creates a variable named 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 expression THEN statement ; In this example, the variable City is assigned a value of Chicago only if the expression AirportCode='ORD' is true.SAS 认证考试样题SAS 中文论坛网站You can learn about IF-THEN statements in Creating and Managing 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: a The DATA step first goes through a compilation phase, then an execution phase. The length of a variable is set during the compilation phase and is based on the first time the variable is encountered. In this case, the variable code is set to the length of the text string DAL523 which is 6 characters long. The next assignment statements are ignored during compilation. The LENGTH statement is also ignored since the length has already been established, but a note will be written to the log.You can learn about•the compilation phase of the DATA step in Understanding DATA StepProcessing• the LENGTH statement in Creating and Managing Variables .16. Which of the following statements creates a numeric variable named 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 sets the name, type, and length of the variable in the program data vector (PDV) and in the output SAS data set. The assignment statement IDnumber=4198; is the first reference and creates a numeric variable named IDnumber with a default storage length of 8 bytes.You can learn about• creating variables in the DATA step in Understanding DATA Step ProcessingSAS 认证考试样题SAS 中文论坛网站• 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 the value for salary is 30000? a.Under 6 b.Under 60 c.Over 60 d. ' ' (missing character value)Correct answer: aThe variable description is being created by the IF-THEN/ELSE statement during compilation. The first occurrence of the variable description is on the IF statement, and since it is assigned the value Over 60, the length of the variable is 7. Therefore, for the salary value of 30000, description has the value of Under 6 (the 0 is truncated.) You can learn about•the compilation phase of the DATA step in Understanding DATA StepProcessing• IF-THEN/ELSE statements in Creating and Managing Variables .18. A raw data file is listed below.1---+----10---+----20---+---10232015The following program is submitted:data all_sales;infile 'file-specification';input receipts;<insert statement(s) here>run;SAS 认证考试样题SAS 中文论坛网站Which statement(s) complete(s) the program and produce(s) a running 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 retain values across iterations of the DATA step. The sum statement total+receipts; initializes total to 0, ignores missing values of receipt , retains the value of total from one iteration to the next, and adds the value of receipts to total .You can learn about the sum statement in Creating and Managing 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 raw data file above: data money;infile 'file-specification';input year quantity;total=total+quantity;run;What is the value of total when the data step finishes executing?a.0 b.1 c.11 d. . (missing numeric value)Correct answer: dThe variable Total is assigned a missing value during the compilation phase of the DATA step. When the first record is read in, SAS processes: total=.+2; which results in a missing value. Therefore the variable Total remains missing for all observations. You can learn about• the compilation phase of the DATA step in Understanding DATA StepProcessingSAS 认证考试样题SAS 中文论坛网站• using missing values with arithmetic operators in Creating SAS Data Sets fromRaw Data .20.The following program is submitted:data test;average=mean(6,4,.,2);run;What is the value of average ?a.0 b.3 c.4 d. . (missing numeric value)Correct answer: cThe MEAN function adds all of the non-missing values and divides 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 Data with 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 in the output data set? a. ( 3)b. (312)c. 3d. 312Correct answer: aAn automatic data conversion is performed whenever a numeric variable is used where SAS expects a character value. The numeric variable is written with the BEST12. format and the resulting character value is right-aligned when the conversion occurs. In this example, the value of Phonenumber is converted to character and right-aligned before the SUBSTR function is performed. 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 blanks and a 3. You can learn about automatic data conversion and the SUBSTR function inTransforming Data with SAS Functions .22.The following SAS program is submitted:data work.inventory;products=7;SAS 认证考试样题SAS 中文论坛网站do until (products gt 6);products+1;end;run;Which one of the following is the value of the variable products in the output data set? a. 5b. 6c. 7d. 8Correct answer: dA DO UNTIL loop always executes at least once because the condition is not evaluated until the bottom of the loop. In the SAS program above, the value of Products isincremented from 7 to 8 on the first iteration of the DO UNTIL loop, before the condition is checked. Therefore the value of Products is 8.You can learn about DO UNTIL loops in Generating Data with 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 creates new 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 valid statement, only AnswerB creates new variables named new_salary1, new_salary2 and new_salary3. AnswerC and AnswerD both create an array that groups the existing data set variables salary1, salary2, and salary3. Since the array in Answer A is named salary , it also uses the existing data set variables.You can learn about creating new variables in an ARRAY statement in Processing Variables with Arrays .24.Which of the following permanently associates a format with a variable?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: bSAS 认证考试样题SAS 中文论坛网站To permanently associate a format with a variable, you use the FORMAT statement in a DATA step. You can use the FORMAT procedure to create a user-defined format. You use the INPUT function to convert character data values to numeric values with an informat. You use the INPUT statement to read data into a data set with an informat. You can learn about•permanently assigning a format to a variable in Creating and Managing Variables •the FORMAT statement in Creating List Reports •the FORMAT procedure in Creating and Applying User-Defined Formats •the INPUT function in Transforming Data with SAS Functions • the INPUT statement in Reading Raw Data in Fixed Fields .25.The following report is generated:Styleof homesn A skingPriceCONDO 4 $99,313RANCH 4 $68,575SPLIT3 $77,983 TWOSTORY4 $83,825Which 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;SAS认证考试样题Correct answer: dThe FREQ procedure cannot create the average asking price. The CLASS statement and the VAR statement are not valid for use with the PRINT procedure. The MEANS procedure output would have both the N statistic and the N Obs statistic since a CLASS statement is used. The REPORT procedure produced the report.You can learn about•the FREQ procedure in Producing Descriptive Statistics•the PRINT procedure in Creating List Reports•the MEANS procedure in Producing Descriptive Statistics•the REPORT procedure in Creating Enhanced List and Summary Reports. 26.A SAS report currently flows over two pages because it is too long to fit within the specified display dimension. Which one of the following actions would change the display dimension so that 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 of lines that compose a page of SAS procedure output. By increasing the number of lines available per page, the report might fit on one page.You can learn about the PAGESIZE= option in Referencing Files and Setting Options.27.Which one of the following SAS REPORT procedure options controls how column headings are displayed over multiple lines?a. SPACE=b. SPLIT=c. LABEL=d. BREAK=Correct answer: bThe SPLIT= option specifies how to split column headings. The SPACE=, LABEL= and BREAK= options are not valid options in PROC REPORT.You can learn about the SPLIT= option for the REPORT procedure in Creating Enhanced List and Summary Reports.SAS中文论坛网站SAS认证考试样题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 or BODY= option in the ODS HTML statement. The ODS HTML CLOSE statement closes the open HTML file and ends the output capture. The Newfile.html file contains the output from the PRINT, MEANS, and FREQ procedures.You can learn about the ODS HTML statement in Producing HTML Output.29.A frequency report of the variable Jobcode in the Work.Actors data set is listed below.Jobcode Frequency Percent CumulativeFrequency CumulativePercentActor I233.33233.33Actor II233.33466.67Actor 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 onlySAS中文论坛网站SAS 认证考试样题SAS 中文论坛网站b. 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 will evaluate 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 Raw Data • the ELSE statement in Creating and Managing Variables .30.The descriptor and data portions of the Work.Salaries data set are shown below. Variable Type Len Posname Char 8 0salary Char 8 16status Char 8 8name status salary Liz S 15,600 Herman S 26,700 Marty S 35,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 been converted to numeric values.d. An ERROR indicating that the WHERE clause operator requires compatible variables. Correct answer: dSalary is defined as a character variable. Therefore, the value in the WHERE statement must be the character value 20,000 enclosed in quotation marks.You can learn about the WHERE statement in Creating List Reports .31.Which of the following statements is true when SAS encounters a syntax error in a DATA step?SAS 认证考试样题SAS 中文论坛网站a. The SAS log contains an explanation of the error.b. The DATA step continues to execute and the resulting data set is complete.c. The DATA step stops executing at the point of the error and the resulting data set contains observations up to that point.d. A note appears in the SAS log indicating that the incorrect statement was saved to a SAS data set for further examination.Correct answer: aSAS scans the DATA step for syntax errors during the compilation phase. If there are syntax errors, those errors get written to the log. Most syntax errors prevent further processing of the DATA step.You can learn about how SAS handles syntax errors in the DATA step in Understanding DATA Step Processing .32.Which TITLE statement would display JANE'S DOG as the text of the title?a. title "JANE"S DOG";b. title 'JANE"S DOG';c. title "JANE'S DOG";d. title 'JANE' ' 'S DOG';Correct answer: cThe title in a TITLE statement must be enclosed in a pair of matched quotation marks. Unbalanced quotation marks can cause problems for SAS. To hide an unmatched single quotation mark, surround the title text with matched double quotation marks.You can learn about•the TITLE statement in Creating List Reports • unbalanced quotation marks in Editing and Debugging SAS Programs .33.The following SAS program is submitted:data test;input animal1 $ animal2 $mlgrams1 mlgrams2;cards;hummingbird ostrich 54000.39 90800000.87;run;Which one of the following represents the values of each variable in the output data set?a. animal1 animal2 mlgrams1 mlgrams2 hummingb ostrich 54000.39 90800000b. animal1 animal2 mlgrams1 mlgrams2 hummingb ostrich 54000.39 90800000.87c. animal1 animal2 mlgrams1 mlgrams2 hummingbird ostrich 54000.39 90800000d. animal1 animal2 mlgrams1 mlgrams2。
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~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 $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;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.855.8Teen 6 56.5 66.563.0M Pre-Teen 4 57.3 64.859.7Teen 6 62.5 72.066.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 Western Los Angeles CA Western BangorC.City State Region ----------- ----- ------- Tulsa OK Central Los Angeles CA Western Bangor WesternD.City State Region ----------- ----- ------- Tulsa OK Central Los CA Western BangorAnswer: 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 5 DGTY23 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 outputWORK.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 has been assigned a permanent label of "Open Date". Which SAS program temporarilyreplaces 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 523 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 B 693 B 704 A 82 4 C 91B.X Y Z -- -- -- 1 A 271 B 452 A 522 B 693 B 704 A 82 4 C 91C.X Y Z -- -- -- 1 A 33 1 B 452 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。
SAS-base-考试必备-70真题(附答案)
following SAS program is submitted:data ;set ;by Department Gender;\if First.<_insert_code_> then Payroll=0;Payroll+Wagerate;if Last.<_insert_code_>;run;)The SAS data set is currently ordered by Gender within Department.Which inserted code will accumulate subtotals for each Gender within DepartmentA. GenderB. DepartmentC. Gender Department…D. Department GenderAnswer: A-------------------------------------the following raw data records in :{----|----10---|----20---|----30John,FEB,13,25,14,27,FinalJohn,MAR,26,17,29,11,23,CurrentTina,FEB,15,18,12,13,Final)Tina,MAR,29,14,19,27,20,CurrentThe following output is desired:Obs Name Month Status Week1 Week2 Week3 Week4 Week5>1 John FEB Final $13 $25 $14 $27 .2 John MAR Current $26 $17 $29 $11 $233 Tina FEB Final $15 $18 $12 $13 .4 Tina MAR Current $29 $14 $19 $27 $20 :Which SAS program correctly produces the desired outputA.data ;—length Name $ 4 Month $ 3 Status $ 7;infile '' 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=;run;>B.data ;length Name $ 4 Month $ 3 Status $ 7;infile '' 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=;】run;C.data ;length Name $ 4 Month $ 3 Status $ 7;【infile '' 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=;run;D.>data ;length Name $ 4 Month $ 3 Status $ 7;infile '' 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=;run;{Answer: C-------------------------------------Excel workbook contains the following four worksheets:EAST·WESTNORTHSOUTHThe following program is submitted:~libname MYXLS '';Which PROC PRINT step correctly displays the NORTH worksheetA. proc print data=;run;|B. proc print data=$;run;C. proc print data=MYXLS.'NORTH'e;run;D. proc print data=MYXLS.'NORTH$'n;run;Answer: D—-------------------------------------following SAS program is submitted:data ;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-------------------------------------statement specifies that records 1 through 10 are to be read from the raw data fileA. infile '' 1-10;!B. input '' stop@10;C. infile '' obs=10;D. input '' stop=10;Answer: C<-------------------------------------a SAS program is submitted, the following is written to the SAS log:101 data ;102 set (keep=product month num_Sold Cost);(103 if Month='Jan' then output ;104 Sales=Cost * Num_Sold;105 keep=Product Sales;-----22,ERROR 22-322: Syntax error, expecting one of the following: !,!!, &, *, **, +, -, , <=, <>, =, >, >=,AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL,NOTIN, OR, ^=, |, ||, ~=.106 run;What changes should be made to the KEEP 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-------------------------------------of the following choices is an unacceptable ODS destination for producing output that can be viewed in Microsoft Excel^A. MSOFFICE2KB. EXCELXPC. CSVALLD. WINXP/Answer: D-------------------------------------SAS data set named contains 10 observations for each department,and is currently ordered by Department. The following SAS program is submitted:~data ;set (keep=Department MonthlyWageRate);by Department;if =1 then Payroll=0;/Payroll+(MonthlyWageRate*12);if =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 data set.D. The values of the variable Payroll represent a monthly total for all values of WAGERATE in the data set.!Answer: C-------------------------------------following SAS program is submitted:*data ;Cost='$20,000';Discount=.10*Cost;run;{What is the resultA. The value of the variable Discount in the output data set is messages are written to the SAS log.B. The value of the variable Discount in the output data set is 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.。
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 定义一个变量, 其值是指针所在的当前列位置。
SASbase考试必备70真题(附答案)
t ted:;Y;r;l l=0;a te;d e_>;run;The SAS data set.?rrr: A-------------------------------------I LE.TXT:----|----10---|----20---|----30n tTina,MAR,29,1n te d:$13 $25 $14 $27 .n t $26 $17 $29 $11 $23$15 $18 $12 $13 .n t $29 $14 $19 $27 $20t?A.R S;s $ 7;I LE.TXT' dsd;$;s $;s $;-r6.;run;R S;run;B.R S;s $ 7;v er;$;='FEB' s $;s $;-r6.;run;R S;run;C.R S;h s $ 7;I LE.TXT' dlm=',';$ @;s $;s $;f-r6.;run;R S;run;D.R S;s $ 7;I LE.TXT' dsd @;$;Week s $;s $;-r6.;run;R S;run;r: C-------------------------------------wo: EASTWESTt ted:n s.xls';h eet?;run;$;run;'e;run;$'n;run;r: D-------------------------------------w t ted:I NFO;Day="01" ;Yr=1960 ;X=mdy(Day,01,Yr) ;run;b le X?960"n g v si on.r: A-------------------------------------g h 10 are to be read from them er.txt?m er.txt' 1-10;m er.txt' stop@10;m er.txt' obs=10;m er.txt' stop=10;r: C-------------------------------------a S e n to the SAS log:R Y;o ld Cost);R Y;o ld;1;-----22-w ing: !,!!, &, *, **, +, -, , <=, <>, =, >, >=,AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, OR, ^=, |, ||, ~=.106 run;s in the LOG?);;;c t Sa;r: D-------------------------------------?X PLr: D-------------------------------------t ted:data WORK.;);;l l=0;*12);=1;run;m ent is true?A. T..t men Y data set.Y data set.r: C-------------------------------------a m is sub t ted:L;Cost='$20,000';u nt=.10*Cost;run;t?e n to the SAS log.e n to the SAS log.n g.i c data.e n to the SAS log.r: C 因为有一个$符号-------------------------------------a m:t;age plow-12 ='Pre-Teen'13-high = 'Teen';run;;t;Sex Age;p.;run;tot s:tNu m Mean ------------------------------------------------------------------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 --------------------------------------------------------------------c=1;c=1 ;dat c=1;c=1;r: C-------------------------------------: JANFEBMARst o ok?t a 'qtr1.xls';s=3;m e jan feb mar 'qtr1.xls';=(jan,feb,mar);r: A-------------------------------------t ted:data WORK.TEST;);-u nt3;;run;e d?u nt3n ts3r: A-------------------------------------g er:A.;S;t ate,2,' ');a l';run;B.data WORK.TES g er;S;t ate,2,' ');a l';run;C.;S;t ate,2,' ');a l';run;D.g er;S;t ate,2,' ');a l';run;r: c-------------------------------------R_?t ion.m ent.n.l ly dro e d.r: D-------------------------------------t ted:I NFO;2005'd;=day(x);(x);Year=year(x);run;of r, and Year?c ter.i c.c ter.D s.r: B-------------------------------------w ing data step:data WORK.GEO;i nes;City $20.;' then='OK';a l';e s' then='CA';r n';i nes;e sr;run;i n?A.C n----------- ----- -------r nr nr nB.n----------- ----- -------r nr nrC.n----------- ----- -------a lr nr nD.City n----------- ----- -------a lr nrr: A-------------------------------------a ticR_?s in a DATA step.e d.C. The _E s in the DATA step..r: C-------------------------------------iChar:WORK.ONENum Char--- ----1 233 231 77t ted:data=WORK.ONE;Num='1';run;t?A.Num Char--- ----1 23B.Num Char--- ----1 231 77C.Num Char--- ----1 233 231 77a ted.r: D-------------------------------------t of 7.;t ted:U RE;F ee C n t7.2;S TAT;F ee/100;/100;run;e t?t of 9. a t of 7.n t7.2n t7.2t for Lo F ee.r: C-------------------------------------C TS:n s------ ----- ----------- ----- -------O R 15 2I NG 300 10M ENT 25 5O R 125 15O R 45 53M ENT 67 2t ted:;C TS;GT 30;O R;;; run;i n?A. 1B. 2C. 3D. 6r: B-------------------------------------r y?n ts lib=WORK run;n ts lib=WORK.all;run;; run;; run;r: c-------------------------------------m ent?n_";n_";n_";n_";r: C-------------------------------------d s:----|----10---|----20---|----30*12/29/1970*10e l**6e d:4015 10e l . 6in the raw data?A.dat y ees;i on' dlm='*';;run;B.y ees;i on' dsd='*';;run;C.dat y ees;i on' dlm dsd;;run;D.y ees;i on' dlm='*' dsd;;run;r: D-------------------------------------w ing code:o bs=5 obs=15);Sex='M';run;a yed?A. 11B. 15r: D-------------------------------------r ary SAS data set?A.proc sort out=E R T;;run;B.R T;;run;C.R T;;run;D.proc sort R T;;run;r: B-------------------------------------:Temp--- ----- ----1 May 7515 May 7015 June 803 June 762 July 8514 July 89t ted:;Day; run;; run;c t?A.Temp--- --- ----- ----1 2 July 852 14 July 893 3 June 764 15 June 805 1 May 756 15 May 7B.Obs Day Temp --- --- ----- ----1 1 May 752 2 July 853 3 June 764 14 July 895 15 May 706 15 June 80C.Temp--- --- ----- ----1 1 May 752 15 May 703 3 June 764 15 June 805 2 July 856 14 July 89D.Temp--- --- ----- ----1 15 May 702 1 May 753 15 June 804 3 June 765 14 July 896 2 July 85r: C-------------------------------------the SAS data set WO:00-------- -------1562:08-------- -------a328e d:2n es the data?A.r e;)(in=_b);;if _a and _b;-00;run;B.r e;));;if _a and _b;-00;run;C.r e;WORK.P))(in=_b);;if _a and _b;-00;run;D.r e;))(in=_b);;if _a and _b;-00;run;r: C-------------------------------------t ted:data ;I LE.TXT';n y $20. @25 St$2. @;@30 Year;@30 City Year;e s;run;t ion of the DATA step?A. 1B. 2C. 3D. 4r: A-------------------------------------a yed in the SAS Log:y in line 4 15-23.RULE: ----+----1----+----2----+----3----+----4----+----5--1954 33-R_=1 _N_=4y ees.dat'.h was 33.h was 33.b les. What does it mean?y.B. An e y.n.y.r: B------------------------------------------------------------------I LE.TXT:----|----10---|----20---|----30sa llt ted:O;-3 $ 10;I LE.TXT' dlm=',';3 $;run;data=WORK.SPOR O;run;a m?A.3sa llrB.3sa llC.Spor3srD.3s2 Bil a llr: C------------------------------------------------------------------w ing data step:data WORK.NEW;set WORK.OLD;+1;run;m ent. Whb le is true?t ion.t ion.l e time.l e time.r: C------------------------------------------------------------------t ted:data WORK.TEST;S;';w n';run;n?2w n)r: B-------------------------------------------------------------------d?o gB. in a mer yr yr: Ao g------------------------------------------------------------------T A.TWO:X Y-- --5 23 15 6t ted:;T A.TWO;if X eq 5 then E R.ONE;E R.TWO;t;run;t?A.n sn sn sB.n sn sn sC.n sn sdata set WORK.OT n ss.r: A------------------------------------------------------------------Y EE.TXT':----+----10---+----20---+----30--Xing 2 19 2004 ACCTBob 5 22 2004 MKTG3 14 2004 EDUCt ted:Y EE;Y EE.TXT';N ame $D ate$;run;a m?.y10.y10..r: B-------------------------------------------------------------hasyt?A.;i ng Date";run;B.;i ng Date";run;C.data=SASU S;i ng Date";run;D.S;i ng Date";run;r: B------------------------------------------------------------------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 91t ted: data WORK.TWO;set WORK.ONE;by X Y;.Y;run;; run;c ed?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 uref e d in the DATA step.r: B------------------------------------------------------------------t ted:R S;i tes{3} $ 8 f rey');run;R S?g wayg wa)b les are e d.r: B------------------------------------------------------------------t ted:C TS;Prod=1;(Prod LE 6);Prod + 1;end;run;of t data set?A. 6B. 7C. 8i c)r: B------------------------------------------------------------------.txt:----|----10---|----20---|----30---|304-923-3721 14t ted:S;.txt';s ion;d e_>run;a me?a me);a me);a a me;a me;r: A------------------------------------------------------------------t ted:data WORK.ONE;r k';Pos=find(Text,'US','i',5);run;n to Pos?A. 0B. 1C. 2D. 12r: D------------------------------------------------------------------S:Se d-------- ------------ ---------200920092009,t.n ote,m er name.n".n ote?n otm er);m er);w r m er);m er);r: D------------------------------------------------------------------a m i t ted:E R.TWOE R.ONE;run;e d?e dB. 3 te e de de dr: D------------------------------------------------------------------t ted:l file='c:\test.cvs';data=WORK.ONE;;b er;run;;t?.r.r.test.cvs that can d by SAS.r: C------------------------------------------------------------------the SAS data set WORK.ONE:--- ----------- ----------- -----------1 1.2 1.6 2.0t ted:data WORK.TWO;set WORK.ONE;=mean(of Rev:);run;?A. 3B. 1.6C. 4.8s.r: B------------------------------------------------------------------d ure:d ureof reg c tc te ncy|n t |Row Pct |---------+--------+--------+--------+EAST | 2 | 1 | 1 | 4| 22.22 | 11.11 | 11.11 | 44.44| 50.00 | 25.00 | 25.00 || 50.00 | 33.33 | 50.00 |---------+--------+--------+--------+| 2 | 2 | 1 | 5| 22.22 | 22.22 | 11.11 | 55.56| 40.00 | 40.00 | 20.00 || 50.00 | 66.67 | 50.00 |---------+--------+--------+--------+4 3 2 944.44 33.33 22.22 100.00n ate the row an ts?n tn tsr: C------------------------------------------------------------------ 48.The f t ted:data WORK.TEST;drop City;i nes;Name $ 1-14 /s s $ 1-14 /City $ 1-12 ;$2.;;i nes;y123 Main St.WInAve.New YorkNYoaCA;i n?A.Name Add-------------- ---------------- ------y123 Main St.Ave. NYoB.-------------- ---------------- ----------- ------Ave. New York NYaC.-------------- ---------------- ------Ave. NYin the data step.r: A------------------------------------------------------------------49.The fol t ted:{12}););{12};do i=1 to 12;;end;drop i;run;s.?n.*).C. The k{12}..r: A------------------------------------------------------------------the SAS data set WORK.ONE:Id--- -----111 A158 B329 C644 Dand the SAS data set WORK.TWO:--- -----111 E538 F644 Gt ted:data WORK.BOTH;set WORK.ONE WORK.TWO;by Id;run;n in SAS data set WORK.BOTH?--- ----- -----111 AB.--- ----- -----111 EC.--- ----- -----111 A ED.--- ----- -----644 D Gr: A------------------------------------------------------------------t ted:;run;a m?r y.n ts of the SAS data sets that arer y.r y.data sets.r: D------------------------------------------------------------------A ME:---- -----Jill 1864Jack 2121Joan 4698John 5463E PT:----- ----------c et ingt ted:data WORK.ALL;A ME));;);run;a m?A. 1B. 2C. 3D. 5r: B------------------------------------------------------------------t ted:R Y;;Y;;.De=0;a te);;run;?A. 0n ga tet br: B------------------------------------------------------------------w ing data step:data WORK.TEST;(obs=5);';';run;a m is true?A. a ted to 8e d.newi e.a tede d.n ed one time, S.r: D------------------------------------------------------------------t ted:I NFO;1960" D ;run;?1960"960t e.r: D 注意D前面有空格------------------------------------------------------------------d ure:d urec tc te ncy|n t |Row Pct |---------+--------+--------+--------+EAST | 2 | 1 | 1 | 4| 22.22 | 11.11 | 11.11 | 44.44| 50.00 | 25.00 | 25.00 || 50.00 | 33.33 | 50.00 |---------+--------+--------+--------+| 2 | 2 | 1 | 5| 22.22 | 22.22 | 11.11 | 55.56| 40.00 | 40.00 | 20.00 || 50.00 | 66.67 | 50.00 |---------+--------+--------+--------+4 3 2 944.44 33.33 22.22 100.00a mt?;d e_>run;s c t;c tc t;c t;r: D------------------------------------------------------------------the SAS data set WORK.ONE:N Be D ate- ---------20102010t ted:data WORK.TWO;set WORK.ONE;d e_>;.;run;e d, whera y, ... :WORK.TWOD ate Day- --------- ---2010 12010 4e b le Day?D ate)D ate)D ate)())r: B------------------------------------------------------------------a t ted:t;t.-= 'Less than 50K'-e r';o=1;t';;a te;tt..;y ee'y'a te='Date of Hire';run;a m fail?m ent.d ure.m ent.n g f m ent.r: C------------------------------------------------------------------O LOR.DAT:----+----10---+----20---+----30ww ing SAS pr t ted:R S;o ver;hType $ 5$ 11;Type $$;run;?A. T w=ww=r: D------------------------------------------------------------------C TS:n s------ ----- ----------- ----- -------O R 15 2I NG 300 10251.99 EQUI M ENT 25 5O R 125 15O R 45 5M ENT 67 2t ted:data WORK);n s);-n s);run;i n?A. 2B. 3C. 4D. 6r: A------------------------------------------------------------------d er the data step:data WORK.TEST;1.csv' dsd;t;=1;=2;run;?=2;=2;=2;D. both A or C will work.r: A------------------------------------------------------------------t ted:e_>;e r' , 'Boot');run;e_>,d in an html file?A..html';;B..html' / html;;C..html';;D..html';;Answ r: C------------------------------------------------------------------t ted:;(Prod GT 6);Prod + 1;end;run;b le Prod t data set?n g)B. 6C. 7i te loop.r: C------------------------------------------------------------------t ted:data WORK.;;n';run;e t?word).).n.e d in a PROC step.r: C------------------------------------------------------------------t ted:;do Year=1 to 5;=1 to 12;X + 1;end;end;run;n s are wri data set?A. 0B. 1C. 5D. 60r: B------------------------------------------------------------------w ing data step:data WORK.NEW;set WORK.OLD(keep=X);if X < 10 then X=1;else if X >= 10 AND X LT 20 then X=2;else X=3;run;?A.of 1.of 3.n g.s.r: A n g data 最小------------------------------------------------------------------t ted:;;$6;;run;,we t?i c.w n.c ter.a m fail s.r: D------------------------------------------------------------------T A:e r_i ID------- ---------------------- ---------------- ------11111 one oe r'?-e r';-E R';e r ';e r%';r: D------------------------------------------------------------------e n to the SAS log:R Y;i ty Cost);R Y;i ty;i ty Cost;-----22-w ing: !,!!, &, *, **, +, -,, <=, <>, =, >, >=,AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL,, OR, ^=, |, ||, ~=.110 run;in the log?i ty Cost)i ty, Cost)i ty, Cost)i ty Cost)r: D------------------------------------------------------------------。
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 Base认证考试 真题 答案详解
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 123试题+答案详解
QUESTION 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。
SAS base 50题 训练题(含答案及解析)
SAS 中文论坛网站1.A raw data file is listed below.1---+----10---+----20---+---son Frank 01/31/89daughter June 12-25-87brother Samuel 01/17/51The following program is submitted using this file as input:data work.family;infile 'file-specification';<insert INPUT statement here >run;Which INPUT statement correctly reads the values for the variable Birthdate as SAS date values?a. i nput relation $ first_name $ birthdate date9.;b.i nput relation $ first_name $ birthdate mmddyy8.; c.i nput relation $ first_name $ birthdate : date9.; d.i nput relation $ first_name $ birthdate : mmddyy8.; Correct answer: dAn informat is used to translate the calendar date to a SAS date value. The date values are in the form of two-digit values for month-day-year, so the MMDDYY8. informat must be used. When using an informat with list input, the colon-format modifier is required to correctly associate the informat with the variable name.You can learn about•informats in Reading Date and Time Values • the colon-format modifier in Reading Free-Format Data .2.A raw data file is listed below.1---+----10---+----20---+---Jose,47,210Sue,,108The following SAS program is submitted using the raw data file above as input: data employeestats;<insert INFILE statement here>input name $ age weight;run;The following output is desired:name age weight Jose 47 210 Sue . 108Which of the following INFILE statements completes the program and accesses the data correctly?a. infile 'file-specification ' pad;b. infile 'file-specification ' dsd;SAS 中文论坛网站c. infile 'file-specification ' dlm=',';d. infile 'file-specification ' missover;Correct answer: bThe PAD option specifies that SAS pad variable length records with blanks. TheMISSOVER option prevents SAS from reading past the end of the line when reading free formatted data. 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 as delimiters and two consecutive commas indicating a missing value 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 Multiple Observations from a SingleRecord• 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 second observation?a.brown b.spencer c.' ' (missing character value) d. There is no value because only one observation is created.Correct answer: dThe CARDS statement enables you to read instream data. Any number of consecutive commas are considered to be a single delimiter as a result of the DLM= option, and the length of each variable defaults to 8 bytes. Therefore, the values jones , brownjon , and spencer are assigned to Agent1, Agent2, and Agent3, respectively, for the firstobservation. The rest of the data on the record is not read by the INPUT statement and is not output to the data set.You can learn about•the CARDS statement in Creating SAS Data Sets from Raw Data • the default length of variables in Reading Free-Format Data .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 raw data 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 in Answer b, the variable Baths in Answer d, and the variable Price in Answer a (which is also missing a dollar sign to read the variable Street as a character value).You can learn about formatted input and informats in Reading Raw Data in Fixed Fields.5. The following SAS program is submitted at the start of a new SAS session:libname sasdata 'SAS-data-library';data sasdata.sales;set sasdata.salesdata;profit=expenses-revenues;run;SAS中文论坛网站SAS 中文论坛网站proc print data=sales;run;The SAS data set Sasdata.Salesdata has ten observations. Which one of the following explains why a report fails to generate?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 PRINTprocedure is printing a temporary SAS data set, Sales , that is stored in the Work library. At the beginning of the SAS session, Work.Sales does not exist.You can learn about•creating permanent data sets with the DATA step in Creating SAS Data Setsfrom Raw Data• temporary data sets in Basic Concepts . 6. Which action assigns a reference named SALES to a permanent SAS 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 libref to a permanent SAS data library. The LIBNAME command opens the LIBNAME window.You can learn about the LIBNAME statement in Referencing Files 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 the program and selects only observations with a Hire_date of February 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-digit day, three-digit month, and two- or four-digit year, enclosed in quotation marks and followed by a d('ddmmmyy<yy>'d).You can learn about SAS date constants in Creating SAS Data Sets from Raw Data. 8. Which one of the following SAS date formats displays the SAS date 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 bytes long, so DDMMYY10. is the correct format. Although WEEKDATE10. is a valid SAS format, it does not display the SAS date value as shown in the question above. DDMMYYYY10. is not a valid SAS date format, and the DATE 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 Time Values.9. Which one of the following displays the contents of an external file 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 the values in SAS data sets. The FSLIST procedure displays the values in external files. There is no LIST procedure in SAS.You can learn about•the PRINT procedure in Creating List ReportsSAS中文论坛网站SAS 中文论坛网站• the VIEWTABLE window in Referencing Files and Setting Options .10. The SAS data set Sashelp.Prdsale contains the variables Region and Salary with 4 observations per Region . Sashelp.Prdsale is sorted primarily by Region and within Region 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 to the output data set? a. 0b. 1c. 2d. 4Correct answer: cThe expression first.region is true once for each region group. The expression last.region is true once for each region group. Therefore, each OUTPUT statement executes once for a total of 2 observations in the output data set.You can learn about the FIRST.variable expression and the OUTPUT 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 the CONTENTS procedure. Data Set NameSASUSER.HOUSES Observations 15 Member TypeDATA Variables 6 EngineV9 Indexes 0 CreatedTuesday, April 22, 2003 03:09:25 PMObservation Length 56 Last ModifiedTuesday, April 22, 2003 03:09:25 PMDeleted Observations0 Protection CompressedNOData Set Type Sorted NOLabel Residential housingfor saleData Representation WINDOWS_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 CONTENTS procedure, In the top right-hand column of the output, you see that Indexes has a value of 0, which indicates that no indexes exist for this data set. Also, Sorted has a value of NO, which indicates that the data is not sorted.You can learn about the CONTENTS procedure in Referencing Files 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 are sorted?a. The data set Work.Test is stored in ascending order by both Fname and Salary values.b. The data set Work.Test is stored in descending order by both Fname and Salary values.c. The data set Work.Test is stored in descending order by Fname and ascending order by Salary values.d. The data set Work.Test is stored in ascending order by Fname and in descending order by Salary values.Correct answer: dThe DESCENDING keyword is placed before the variable name it modifies in the BY statement, so the correct description is in descending order by Salary value within ascending Fname values.You can learn about the SORT procedure and the DESCENDING keyword in Creating List Reports.13.The following SAS program is submitted:data names;SAS中文论坛网站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 variable Division in the output data set?catiocationc.Human Red.Human ResourcesCorrect answer: bThe length of the variable Division is set to 9 when the DATA step compiles. Since the value of the variable Title is EDU, the first IF condition is true; therefore, the value of the variable Division is Education.You can learn about•the length of a variable in Understanding DATA Step Processing•IF-THEN statements in Creating and Managing Variables.14.Which one of the following SAS programs creates a variable named 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 expression THEN statement;In this example, the variable City is assigned a value of Chicago only if the expression AirportCode='ORD' is true.SAS中文论坛网站SAS 中文论坛网站You can learn about IF-THEN statements in Creating and Managing 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 an execution phase. The length of a variable is set during the compilation phase and is based on the first time the variable is encountered. In this case, the variable code is set to the length of the text string DAL523 which is 6 characters long. The next assignment statements are ignored during compilation. The LENGTH statement is also ignored since the length has already been established, but a note will be written to the log.You can learn about•the compilation phase of the DATA step in Understanding DATA StepProcessing• the LENGTH statement in Creating and Managing Variables .16. Which of the following statements creates a numeric variable named 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 sets the name, type, and length of the variable in the program data vector (PDV) and in the output SAS data set. The assignment statement IDnumber=4198; is the first reference and creates a numeric variable named IDnumber with a default storage length of 8 bytes.You can learn about• creating variables in the DATA step in Understanding DATA Step ProcessingSAS 中文论坛网站• 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 the value for salary is 30000? a.Under 6 b.Under 60 c.Over 60 d. ' ' (missing character value)Correct answer: aThe variable description is being created by the IF-THEN/ELSE statement during compilation. The first occurrence of the variable description is on the IF statement, and since it is assigned the value Over 60, the length of the variable is 7. Therefore, for the salary value of 30000, description has the value of Under 6 (the 0 is truncated.) You can learn about•the compilation phase of the DATA step in Understanding DATA StepProcessing• IF-THEN/ELSE statements in Creating and Managing Variables .18. A raw data file is listed below.1---+----10---+----20---+---10232015The following program is submitted:data all_sales;infile 'file-specification';input receipts;<insert statement(s) here>run;SAS 中文论坛网站Which statement(s) complete(s) the program and produce(s) a running 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 retain values across iterations of the DATA step. The sum statement total+receipts; initializes total to 0, ignores missing values of receipt , retains the value of total from one iteration to the next, and adds the value of receipts to total .You can learn about the sum statement in Creating and Managing 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 raw data file above: data money;infile 'file-specification';input year quantity;total=total+quantity;run;What is the value of total when the data step finishes executing?a.0 b.1 c.11 d. . (missing numeric value)Correct answer: dThe variable Total is assigned a missing value during the compilation phase of the DATA step. When the first record is read in, SAS processes: total=.+2; which results in a missing value. Therefore the variable Total remains missing for all observations. You can learn about• the compilation phase of the DATA step in Understanding DATA StepProcessingSAS 中文论坛网站• using missing values with arithmetic operators in Creating SAS Data Sets fromRaw Data .20.The following program is submitted:data test;average=mean(6,4,.,2);run;What is the value of average ?a.0 b.3 c.4 d. . (missing numeric value)Correct answer: cThe MEAN function adds all of the non-missing values and divides 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 Data with 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 in the output data set? a. ( 3)b. (312)c. 3d. 312Correct answer: aAn automatic data conversion is performed whenever a numeric variable is used where SAS expects a character value. The numeric variable is written with the BEST12. format and the resulting character value is right-aligned when the conversion occurs. In this example, the value of Phonenumber is converted to character and right-aligned before the SUBSTR function is performed. 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 blanks and a 3. You can learn about automatic data conversion and the SUBSTR function inTransforming Data with SAS Functions .22.The following SAS program is submitted:data work.inventory;products=7;SAS 中文论坛网站do until (products gt 6);products+1;end;run;Which one of the following is the value of the variable products in the output data set? a. 5b. 6c. 7d. 8Correct answer: dA DO UNTIL loop always executes at least once because the condition is not evaluated until the bottom of the loop. In the SAS program above, the value of Products isincremented from 7 to 8 on the first iteration of the DO UNTIL loop, before the condition is checked. Therefore the value of Products is 8.You can learn about DO UNTIL loops in Generating Data with 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 creates new 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 valid statement, only AnswerB creates new variables named new_salary1, new_salary2 and new_salary3. AnswerC and AnswerD both create an array that groups the existing data set variables salary1, salary2, and salary3. Since the array in Answer A is named salary , it also uses the existing data set variables.You can learn about creating new variables in an ARRAY statement in Processing Variables with Arrays .24.Which of the following permanently associates a format with a variable?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: bSAS 中文论坛网站To permanently associate a format with a variable, you use the FORMAT statement in a DATA step. You can use the FORMAT procedure to create a user-defined format. You use the INPUT function to convert character data values to numeric values with an informat. You use the INPUT statement to read data into a data set with an informat. You can learn about•permanently assigning a format to a variable in Creating and Managing Variables •the FORMAT statement in Creating List Reports •the FORMAT procedure in Creating and Applying User-Defined Formats •the INPUT function in Transforming Data with SAS Functions • the INPUT statement in Reading Raw Data in Fixed Fields .25.The following report is generated:Styleof homesn A skingPriceCONDO 4 $99,313RANCH 4 $68,575SPLIT3 $77,983 TWOSTORY4 $83,825Which 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 for use with the PRINT procedure. The MEANS procedure output would have both the N statistic and the N Obs statistic since a CLASS statement is used. The REPORT procedure produced the report.You can learn about•the FREQ procedure in Producing Descriptive Statistics•the PRINT procedure in Creating List Reports•the MEANS procedure in Producing Descriptive Statistics•the REPORT procedure in Creating Enhanced List and Summary Reports. 26.A SAS report currently flows over two pages because it is too long to fit within the specified display dimension. Which one of the following actions would change the display dimension so that 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 of lines that compose a page of SAS procedure output. By increasing the number of lines available per page, the report might fit on one page.You can learn about the PAGESIZE= option in Referencing Files and Setting Options.27.Which one of the following SAS REPORT procedure options controls how column headings are displayed over multiple lines?a. SPACE=b. SPLIT=c. LABEL=d. BREAK=Correct answer: bThe SPLIT= option specifies how to split column headings. The SPACE=, LABEL= and BREAK= options are not valid options in PROC REPORT.You can learn about the SPLIT= option for the REPORT procedure in Creating Enhanced List and Summary Reports.SAS中文论坛网站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 or BODY= option in the ODS HTML statement. The ODS HTML CLOSE statement closes the open HTML file and ends the output capture. The Newfile.html file contains the output from the PRINT, MEANS, and FREQ procedures.You can learn about the ODS HTML statement in Producing HTML Output.29.A frequency report of the variable Jobcode in the Work.Actors data set is listed below.Jobcode Frequency Percent CumulativeFrequency CumulativePercentActor I233.33233.33Actor II233.33466.67Actor 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 onlySAS中文论坛网站SAS 中文论坛网站b. 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 will evaluate 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 Raw Data • the ELSE statement in Creating and Managing Variables .30.The descriptor and data portions of the Work.Salaries data set are shown below. Variable Type Len Posname Char 8 0salary Char 8 16status Char 8 8name status salary Liz S 15,600 Herman S 26,700 Marty S 35,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 been converted to numeric values.d. An ERROR indicating that the WHERE clause operator requires compatible variables. Correct answer: dSalary is defined as a character variable. Therefore, the value in the WHERE statement must be the character value 20,000 enclosed in quotation marks.You can learn about the WHERE statement in Creating List Reports .31.Which of the following statements is true when SAS encounters a syntax error in a DATA step?SAS 中文论坛网站a. The SAS log contains an explanation of the error.b. The DATA step continues to execute and the resulting data set is complete.c. The DATA step stops executing at the point of the error and the resulting data set contains observations up to that point.d. A note appears in the SAS log indicating that the incorrect statement was saved to a SAS data set for further examination.Correct answer: aSAS scans the DATA step for syntax errors during the compilation phase. If there are syntax errors, those errors get written to the log. Most syntax errors prevent further processing of the DATA step.You can learn about how SAS handles syntax errors in the DATA step in Understanding DATA Step Processing .32.Which TITLE statement would display JANE'S DOG as the text of the title?a. title "JANE"S DOG";b. title 'JANE"S DOG';c. title "JANE'S DOG";d. title 'JANE' ' 'S DOG';Correct answer: cThe title in a TITLE statement must be enclosed in a pair of matched quotation marks. Unbalanced quotation marks can cause problems for SAS. To hide an unmatched single quotation mark, surround the title text with matched double quotation marks.You can learn about•the TITLE statement in Creating List Reports • unbalanced quotation marks in Editing and Debugging SAS Programs .33.The following SAS program is submitted:data test;input animal1 $ animal2 $mlgrams1 mlgrams2;cards;hummingbird ostrich 54000.39 90800000.87;run;Which one of the following represents the values of each variable in the output data set?a. animal1 animal2 mlgrams1 mlgrams2 hummingb ostrich 54000.39 90800000b. animal1 animal2 mlgrams1 mlgrams2 hummingb ostrich 54000.39 90800000.87c. animal1 animal2 mlgrams1 mlgrams2 hummingbird ostrich 54000.39 90800000d. animal1 animal2 mlgrams1 mlgrams2。
SASbase考试必备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 anda 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 5 DGTY23 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 outputWORK.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 orSASUSER.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 has been assigned a permanent label of "Open Date". Which SAS program temporarilyreplaces 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.。
SAS-base-考试必备-70真题(附答案)
following SAS program is submitted:data ;set ;by Department Gender;if First.<_insert_code_> then Payroll=0;Payroll+Wagerate;if Last.<_insert_code_>;run;The SAS data set is currently ordered by Gender within Department.Which inserted code will accumulate subtotals for each Gender within DepartmentA. GenderB. DepartmentC. Gender DepartmentD. Department GenderAnswer: Athe following raw data records in :--- | --- 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:Name Month Status Week1 Week2 Week3 Week4 ObsWeek51 John FEB Final $13 $25 $14 $272 John MAR Current $26 $17 $29 $11 $233 Tina FEB Final $15 $18 $12 $134 Tina MAR Current $29 $14 $19 $27 $20Which SAS program correctly produces the desired outputA. data ;length Name $ 4 Month $ 3 Status $ 7; infile '' 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=;run;B.data ;length Name $ 4 Month $ 3 Status $ 7;infile '' 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=; run;C.data ;length Name $ 4 Month $ 3 Status $ 7;infile '' 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=; run;D.data ;length Name $ 4 Month $ 3 Status $ 7;infile '' 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=; run;Excel workbook contains the following four worksheets:EASTWESTAnswer: CNORTHSOUTHThe following program is submitted:libname MYXLS '';Which PROC PRINT step correctly displays the NORTH worksheetA. proc print data=;run;B. proc print data=$;run;C. proc print data=MYXLS.'NORTH'e;run;D. proc print data=MYXLS.'NORTH$'n;run;Answer: Dfollowing SAS program is submitted:data ;Day="01" ;Yr=1960 ;X=mdy(Day,01,Yr) ;run;What is the value of the variable XA. 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: Astatement specifies that records 1 through 10 are to be read from the raw data fileA. infile '' 1-10;B. input '' stop@10;C. infile '' obs=10;D. input '' stop=10;Answer: Ca SAS program is submitted, the following is written to the SAS log:101 data ;102 set (keep=product month num_Sold Cost);103 if Month='Jan' then output ;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, 心,|, II, ~=.106 run;What changes should be made to the KEEP statement to correct the errors in the LOGA. keep=(Product Sales);B. keep Product, Sales;C. keep=Product, Sales;D. keep Product Sales;Answer: Dof the following choices is an unacceptable ODS destination for producing output that can be viewed in Microsoft ExcelA. MSOFFICE2KB. EXCELXPC. CSVALLD. WINXPAnswer: DSAS data set named contains 10 observations for each department,and is currently ordered by Department. The following SAS program is submitted:data ;set (keep=Department MonthlyWageRate);by Department;if =1 then Payroll=0;Payroll+(MonthlyWageRate*12);if =1; run;Which statement is trueA. 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 data set.D. The values of the variable Payroll represent a monthly total for all values of WAGERATE in the data set.Answer: Cfollowing SAS program is submitted:data ;Cost='$20,000';Discount=.10*Cost;run;What is the resultA. The value of the variable Discount in the output data set is messages are written to the SAS log.B. The value of the variable Discount in the output data set is 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 messages are written to the SAS log.Answer: C 因为有一个$符号the existing SAS program:proc format;value agegrp low-12 ='Pre-Teen' 13-high = 'Teen';run;proc means data=;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 MeanF Pre-Teen 3Teen 6M Pre-Teen 4Teen 6A. var Height / nobs min max mean maxdec=1;B. proc means data= maxdec=1 ;C. proc means data= min max mean maxdec=1;D. output nobs min max mean maxdec=1;Answer: CExcel workbook contains the following three worksheets:JANFEBMARWhich statement correctly assigns a library reference to the Excel workbookA. libname qtrdata '';B. libname '' sheets=3;C. libname jan feb mar '';D. libname mydata '' =(jan,feb,mar);Answer: Afollowing SAS program is submitted:data ;set (keep=Janpt Febpt Marpt);array Diff{3} Difcount1-Difcount3; array Patients{3} Janpt Febpt Marpt; run;What new variables are createdA. Difcount1, Difcount2 and Difcount3B. Diff1, Diff2 and Diff3C. Janpt, Febpt, and MarptD. Patients1, Patients2 and Patients3Answer: Aof the following programs correctly invokes the DATA Step Debugger:A.data debug;set ;State=scan(cityState,2,' ');if State='NE' then description='Central'; run;B.data debugger;set ; State=scan(cityState,2,' ');if State='NE' then description='Central'; run;C. data / debug;set ; State=scan(cityState,2,' ');if State='NE' then description='Central';run;D.data / debugger;set ;State=scan(cityState,2,' ');if State='NE' then description='Central'; run;Answer: cstatement 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: Dfollowing SAS program is submitted:data ;X='04jul2005'd;DayOfMonth=day(x);MonthOfYear=month(x);Year=year(x);run;What types of variables are DayOfMonth, MonthOfYear, and YearA. 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: Bthe following data step: data ;infile datalines; input City $20.;if City='Tulsa' thenState='OK';Region='Central';if City='Los Angeles' thenState='CA';Region='Western'; datalines;TulsaLos AngelesBangorJrun;After data step execution, what will data set Answer: A containA.CityTulsaLos Angeles BangorB. CityStateOKCAStateRegionWesternWesternWesternTulsaLos Angeles BangorC. CityOKCAStateRegionWesternWesternTulsaLos Angeles BangorD. CityOK CAStateTulsa Los Bangor OKCARegionCentralWesternWesternRegionCentralWesternstatement 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: CSAS data set contains a numeric variable named Num and a character variable named Char:Num Char1 233 231 77The following SAS program is submitted: proc print data=;where Num='1';run;What is outputA.Num Char1 23B.Num Char231 77C.Num Char1 233 231 77D. No output is generated.Answer: D20. The data set 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 ;format LocalFee CountryFee ;set ;LocalFee=LocalFee/100; CountryFee=CountryFee/100;run;What are the formats of the variables LOCALFEE and COUNTRYFEE in the output datasetA. LocalFee has format of 9. and CountryFee has a format of 7.B. LocalFee has format of 9. and CountryFee has a format ofC. Both LocalFee and CountryFee have a format ofD. The data step fails execution; there is no format for LocalFee.Answer: Cthe SAS data set :ProdId Price ProductType Sales ReturnsK12S OUTDOOR 15 2B132S CLOTHING 300 10R18KY2 EQUIPMENT 25 53KL8BY OUTDOOR 125 15DY65DW OUTDOOR 45 5DGTY23 EQUIPMENT 67 2The following SAS program is submitted:data ;set ;if Sales GT 30;if ProductType EQ 'OUTDOOR' then output ;else if ProductType EQ 'CLOTHING' then output ; else if ProductType EQ 'EQUIPMENT' then output ; run;How many observations does the data set containA. 1B. 2C. 3D. 6Answer: Bstep displays a listing of all the data sets in the WORK libraryA. proc contents lib=WORK run;B. proc contents lib=;run;C. proc contents data=; run;D. proc contents data=WORK _ALL_; run;Answer: cis a valid LIBNAME statementA. 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: Cthe 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 dataA.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: Dthe following code:proc print data=(firstobs=5 obs=15); where Sex='M';run;How many observations will be displayedA. 11B. 15C. 10 or fewerD. 11 or fewerAnswer: Dstep sorts the observations of a permanent SAS data set by two variables and stores the sorted observations in a temporary SAS data setA.proc sort out=EMPLOYEES data=EMPSORT; by Lname and Fname;run;B.proc sort data= out=EMPSORT;by Lname Fname;run;C.proc sort out= data=;by Lname Fname;run;D.proc sort data= out=;by Lname and Fname;run;Answer: Bthe SAS data set :Day Month Temp1 May 7515 May 7015 June 803 June 762 July 8514 July 89The following program is submitted: proc sort data=;by descending Month Day; run;proc print data=;run;Which output is correctA.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 89Obs Day Month Temp 1 15May 70 2 1 May 75 3 15 June 80 4 3 June 76 5 14 July 89 6 2July85Answer: Cthe SAS data set : Location Pop2000Alaska 626931 Delaware 783595 Vermont 608826Wyoming 493782 and the SAS data set : State Pop2008 Alaska 686293 Delaware 873092 Wyoming 532668The following output is desired:(in=_b);by State; if _a and _b;Difference=Pop2008-Pop2000; run;Obs State Pop2000 Pop2008 1 Alaska 626931 686293 2 Delaware 783595 873092 3 Wyoming 493782 532668Difference59362 89497 38886Which SAS program correctly combines the dataA.data compare;merge (in=_a Location=State)data compare;merge (rename=(Location=State))Jby State;if _a and _b;Difference=Pop2008-Pop2000; run;C.data compare;merge (in=_a rename=(Location=State))(in=_b);by State;if _a and _b;Difference=Pop2008-Pop2000; run;D.data compare;merge (in=_a) (rename=(Location=State))(in=_b);by State;if _a and _b;Difference=Pop2008-Pop2000; run;Answer: Cfollowing SAS program is sumbitted:data ;infile '';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 stepA. 1B. 2C. 3D. 4Answer: A 're attempting to read a raw data file and you see the following messagesdisplayed in the SAS Log:NOTE: Invalid data for Salary in line 4 15-23.4 120104 F 46#30 11MAY1954 33 Employee_Id=120104employee_gender=F Salary=. birth_date=-2061 _ERROR_=1 _N_=4NOTE: 20 records were read from the infile 'c:\'.The minimum record length was 33.The maximum record length was 33.NOTE: The data set has 20 observations and 4 variables.What does it meanA. 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 :--- |--- 10---| --- 20---| --- 30 Kim,Basketball,Golf,Tennis Bill,FootballTracy,Soccer,TrackThe following program is submitted:data ; length Fname Sport1-Sport3 $ 10; infile '' dlm=',';input Fname $ Sport1 $ Sport2 $ Sport3 $; run;proc print data=;run;Which output is correct based on the submitted programA.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: Cthe following data step:data ;set ;Cou nt+1;run;The variable Count is created using a sum stateme nt. Which stateme nt regardi ng this variable is trueA. It is assig ned a value 0 whe n the data step begi ns executi on.B. It is assig ned a value of miss ing whe n the data step beg ins executio n.C. It is assigned a value 0 at compile time.D. It is assigned a value of missing at compile time.An swer: Cfollowi ng SAS program is submitted:data ;set ;if Jobcode='Pilot2' then Description='Senior Pilot'; else Descripti on='Unknown';run;The value for the variable Jobcode is: is the value of the variable DescriptionA. PILOT2B. UnknownC. Senior PilotD. ' ' (miss ing character value)An swer: Buser-defi ned format has bee n created using the FORMAT is it storedA. i n a SAS catalogB. i n a memory reside nt lookup tableC. in a SAS dataset in the WORK libraryD. in a SAS dataset in a permanent SAS data librarythe SAS data set :5 23 15 6The following SAS program is submitted: data OTHER;set ;if X eq 5 then output ;if Y lt 5 then output ;output;run;What is the resultA.data set has 5 observations data set has 5 observations data set has 3 observationsB.data set has 2 observations data set has 2 observations data set has 1 observationsC.data set has 2 observations data set has 2 observations data set has 5 observationsD. No data sets are output. The DATA step fails execution due to syntax errors. Answer: Athe contents of the raw data file '':---- + -- 10---+ ----20---+ -- 30--Xing 2 19 2004 ACCTBob 5 22 2004 MKTGJorge 3 14 2004 EDUCThe following SAS program is submitted: data ;infile '';input@1 FirstName $@15 StartDate@25 Department $;run;Which SAS informat correctly completes the programA. date9.B. mmddyy10.C. ddmmyy10.D. mondayyr10.Answer: BSAS data set contains a variable Open_Date which has been assigned a permanent label of "Open Date". Which SAS program temporarily replaces the label "Open Date" with the label "Starting Date" in the outputA.proc print data= label;label Open_Date "Starting Date";run;B.proc print data= label;label Open_Date="Starting Date";run;C.proc print data=;label Open_Date="Starting Date";run;D.proc print data=;Open_Date="Starting Date";run;Answer: Bthe SAS data set :1 A 271 A 331 B 452 A 522 B 693 B 704 A 824 C 91The following SAS program is submitted: data ;set ; by X Y; if ;run;proc print data= noobs; run;Which report is producedXA.Y Z1 B 452 A 522 B 693 B 704 A 82 4 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 is not created in the DATA step.Answer: Bfollowing SAS program is submitted:data ;array Favorites{3} $ 8 ('Shakespeare','Hemingway','McCaffrey'); run;What is the value of the second variable in the datasetA. HemingwayB. HemingwaC. ' ' (a missing value)D. The program contains errors. No variables are created.Answer: Bfollowing SAS program is submitted: data ;Prod=1;do while(Prod LE 6);Prod + 1;end;run;What is the value of the variable Prod in the output data setA. 6B. 7C. 8D. . (missing numeric)Answer: Bthe raw data record in the file :--- |----- 10---| - 20---| --- 30---|Stevens James SALES 304-923-3721 14The following SAS program is submitted:data ;infile '';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 FullNameA. FullName=CATX(' ',EmpFName,EmpLName);B. FullName=CAT(' ',EmpFName,EmpLName);C. FullName=EmpFName!!EmpLName;D. FullName=EmpFName + EmpLName;Answer: Afollowing SAS program is submitted: data ;Text='Australia, US, Denmark'; Pos=find(Text,'US','i',5);run;What value will SAS assign to PosA. 0B. 1C. 2D. 12Answer: Dthe SAS data set :order_id customer shipped9341 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 toship_noteA. 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: Dfollowing SAS program is submitted: data ONE TWOset ;run;Assuming that exists, how many temporary and permanent SAS data sets are createdA. 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: Dfollowing SAS program is submitted:ods csvall file='c:\';proc print data=;var Name Score Grade;by IdNumber;run;ods csvall close;What is produced as outputA. A file named that can only be opened in Excel.B. A text file named that can be opened in Excel or in any text editor.C. A text file named that can only be opened in a text editor.D. A file named that can only be opened by SAS.Answer: Cthe SAS data set :Obs Revenue2008 Revenue2009 Revenue20101The following SAS program is submitted: data ;set ;Total=mean(of Rev:);run;What value will SAS assign to TotalA. 3B.C.D. The program fails to execute due to errors. Answer: Bfollowing output is created by the FREQUENCY procedure: The FREQ ProcedureTable of region by productregion productFrequency|Percent |Row Pct |Col Pct |corn |cotton |oranges |TotalEAST ||||2 ||||SOUTHTotalWhich TABLES option(s) would be used to eliminate the row and column counts and just see the frequencies and percentsA. norowcount nocolcountB. freq percentC. norow nocolD. nocountsAnswer: Cfollowing SAS program is submitted:data ;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 Conley 123 Main St.JanesvilleWIJane Ngyuen555 Alpha Ave. New York NYJennifer Jason666 Mt. Diablo Eureka CAWhat will the data set contain A.Name AddressState 123 Main St.555 Alpha Ave.666 Mt. Diablo B.NameAddress City State Joe Conley123 Main St. Janesville Jane Ngyuen555 Alpha Ave. New York NY Jennifer Jason666 Mt. Diablo Eureka C.NameJane Ngyuen 555 Alpha Ave. NY D. O observations,there is a syntax error in the data step.Answer: Afollowing SAS program is submitted:Joe Conley Jane NgyuenJennifer JasonNY Address Statedata (keep=MonthSales{12});set (keep=Year Product Sales); array MonthSales{12};do i=1 to 12;MonthSales{i}=Sales;end;drop i;run;The program fails execution due to syntax errors.What is the cause of the syntax errorA. 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: Athe SAS data set :Id Char1111 158 329 644 A B C Dand the SAS data set :Id Char2111 E538 F644 GThe following program is submitted:data ; set ; by Id;run;What is the first observation in SAS data setA. Id Char1 Char2111 AB.Id Char1 Char2111 EC.Id Char1 Char2111 A ED.Id Char1 Char2644 D GAnswer: Afollowing program is submitted:proc contents data=_all_;run;Which statement best describes the output from the submitted programA. The output contains only a list of the SAS data sets that are contained in the WORK library.B. The output displays only the contents of the SAS data sets that are contained in the WORK library.C. The output displays only the variables in the SAS data sets that are contained in the WORK library.D. The output contains a list of the SAS data sets that are contained in the WORK library and displays the contents of those data sets.Answer: Dthe SAS data set :Name EmpIDJill 1864Jack 2121Joan 4698John 5463Given the SAS data set :EmpID Department2121 Accounting3567 Finance4698 Marketing5463 AccountingThe following program is submitted:data ;merge (in=Emp_N) (in=Emp_D);by Empid;if (Emp_N and not Emp_D) or (Emp_D and not Emp_N); run; How many observations are in data set after submitting the programA. 1B. 2C. 3D. 5Answer: Bfollowing SAS program is submitted:data ; retain Total; set ; by Department; ifthen Total=0; Total=sum(Total, Wagerate); if ;run;What is the initial value of the variable TotalA. 0B. MissingC. The value of the first observations WagerateD. Cannot be determined from the information given Answer: Bthe following data step:data ;set (obs=5);retain City 'Beverly Hills';State='California';run;The computed variables City and State have their values assigned using two different methods, a RETAIN statement and an Assignment statement. Which statement regarding this program is trueA. The RETAIN statement is fine, but the value of City will be truncated to 8 bytes as the LENGTH statement has been omitted.B. Both the RETAIN and assignment statement are being used to initialize new variables and are equally efficient. Method used is a matter of programmer preference.C. The assignment statement is fine, but the value of City will be truncatedto 8 bytes as the LENGTH statement has been omitted.D. City's value will be assigned one time, State's value 5 times. Answer: Dfollowing SAS program is submitted:data ;X="01Jan1960" D ;run;Variable X contains what valueA. the numeric value 0B. the character value "01Jan1960"C. the date value 01011960D. the code contains a syntax error and does not execute. Answer: D 注意D 前面有空格following output is created by the FREQUENCY procedure:The FREQ ProcedureTable of region by productregion productFrequency|Percent |Row Pct | Col Pct |corn|cotton |oranges | TotalEAST | 2 | 1 || | | || | | || | | |SOUTH | 2 | 2 || | | || | | || | | |Total 4 3 2 9。
SAS_base_考试必备_70真题(附答案)
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;
----|----10---|----20---|----30 John,FEB,13,25,14,27,Final John,MAR,26,17,29,11,23,Current Tina,FEB,15,18,12,13,Final Tina,MAR,29,14,19,27,20,Current
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 定义一个变量, 其值是指针所在的当前列位置。
SBe认证考试真题答案详解
SAS 认证考试—7 0SAS分多个认证种类:base, advaneed , clinic 等,但大多需要先通过base认证。
但凡这类商业组织提供的考证,基本都是题库型,所以想考过难度并不大。
对于只想拿SAS认证的人,如果熟练掌握网上流传甚广的sas真题70题,通过base认证基本就没问题。
Q 11. The following SAS program is submitted:data ;set ;by Department Gender;if First.<_insert_code_> then Payroll=0;Payroll+Wagerate;if Last.<_insert_code_>;run;The SAS data set is currently ordered by Gender within Department.Which inserted code will accumulate subtotals for each Gender within DepartmentA. GenderB. DepartmentC. Gender DepartmentD. Department Gender答案:A 本题知识点:自动变量在SAS读取数据时,在P DV过程中会产生很多自动变量,在输岀的数据集中是不可见的。
•:同一个BY变量(组),若新的变量值第一次岀现时,其值为1。
•:同一个BY变量(组),若新的变量值最后一次岀现时,其值为1。
另外,在BY变量右面有多个变量时,先按第一个变量排序,若第一个变量的观测存在重复时,才按第二个变量排序。
Q 2Given the following raw data records in :- | 10---| 20---| 30John,FEB,13,25,14,27,Final John,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 $134 Tina MAR Current $29 $14 $19 $27 $20Which SAS program correctly produces the desired outputA. data ;length Name $ 4 Month $ 3 Status $ 7;infile '' 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=;run;B. data ;length Name $ 4 Month $ 3 Status $ 7;infile '' 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=;run;C. data ;length Name $ 4 Month $ 3 Status $ 7;infile '' 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=;run;D. data ;length Name $ 4 Month $ 3 Status $ 7;infile '' 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=;run;答案:C 本题知识点:INFILE 语句与指示器@、@@INFILE filespecification options;其中,filespecification 用来定义文件, options 给出选择项;• filespecificati on 有以下三种形式:①、fileref(文件标志)②、' filename '(文件名)③、CARDS旨明输入的数据,紧跟着CARDS吾句•下列选择项(options)可以出现在INFILE 语句中:①、COLUMN=variable 或COL=variable 定义一个变量, 其值是指针所在的当前列位置。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
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 有以下三种形式:
Day="01" ; Yr=1960 ; X=mdy(Day,01,Yr) ; run; What is the value of the variable X? A. the numeric value 0 B. the character value "01011960" C. a missing value due to syntax errors D. the step will not compile because of the character argument in the mdy function.
比较 @ 与 @@ 的区别: ·@ 用于 1 个数据行用多个 input 语句读取,停留到下一个 INPUT 语句。 ·@@ 用于 1 个数据行含有多个观测值读取时,停留到下一个 DATA 步。
Q3 The following SAS program is submitted: data WORK.DATE_INFO;
4
答案:A
本题知识点:数据类型的自动转换 在 SAS 中,日期时间是以 1960 年 1 月 1 日 0 时 0 分 0 秒作为起点的。因此,mdy(1,1,1960)=0。 若把日期时间表示为常数时,要使用相应的格式,带单或双引号,在后面紧跟一个 D(日期)、T(时间)、 DT(日期时间)。 在本题中,日期函数的参数应该是数值,若是字符串,会先尝试字符串是否可以转换为数值,这是自动转 换。 自动转换是指系统产生一个临时的变量来完成赋值或运算。当自动转换发生时,会在 LOG 窗口中给出提示。 1)、字符型变量 -> 数值型变量 在下面的情况中,VarB 是一个字符型变量,其它是数字型变量。 ·赋值于一个数字型变量,如:VarA=VarB; ·在算术运算中使用,如:VarA=VarB+0; ·与一个数字型变量进行比较,如:if VarB>=VarA; ·在函数中,参数要求数字型变量,如:VarA=sum(VarB,0); 2)、数值型变量 -> 字符型变量 在下面的情况中,VarB 是一个数字型变量,其它是字符型变量。 ·赋值于一个字符型变量,如:VarA=VarB; ·在与要求字符的运算符一起使用,如:VarA=''||VarB; ·在函数中,参数要求字符型变量,如:VarA=trim(VarB);
D. proc print data=MYXLS.'NORTH$'n;run; 答案:D 本题知识点:打印 Excel 的某个工作表的数据
WHAT IS THAT “$” CHARACTER? Looking at SAS Explorer it may be surprising that each dataset written to Excel appears twice, once with the
5
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;
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. Gender B. Department C. Gender Department D. Department Gender 答案:A
Q2 Given the following raw data records in TEXTFILE.TXT:
1
----|----10---|----20---|----30 John,FEB,13,25,14,27,Final John,MAR,26,17,29,11,23,Current Tina,FEB,15,18,12,13,Final Tina,MAR,29,14,19,27,20,Current The following output is desired: Obs Name Month Status Week1 Week2 Week3 Week4 Week5 1 John FEB Final $13 $25 $14 $27 . 2 John MAR Current $26 $17 $29 $11 $23 3 Tina FEB Final $15 $18 $12 $13 . 4 Tina MAR Current $29 $14 $19 $27 $20 Which SAS program correctly produces the desired output? A. data WORK.NUMBERS;
Q4 The Excel workbook REGIONS.XLS contains the following NORTH SOUTH The following program is submitted: libname MYXLS 'regions.xls';
named ranges which allow data to be placed anywhere inside a spreadsheet. By default SAS reads and writes data from named ranges on spreadsheets, but will also read spreadsheet data directly in the absence of a named range.
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.;
expected name and once with a trailing “$”. Unlike a typical data source, data in an Excel spreadsheet need not be left and top aligned. For this Excel has