Programming 1 Chapter 2-11

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Correct answer: c RUN, QUIT, DATA, and PROC statements function as step boundaries, which determine when SAS statements take effect and indicate the end of the current step or the beginning of a new step.

1.How many step boundaries does this program contain? data work.staff; length First_Name $ 12 Last_Name $ 18 Job_Title $ 25; infile "&path\newemployees.csv" dlm=','; input First_Name $ Last_Name$ Job_Title $ Salary; run; proc print data=work.staff; run; proc means data=work.staff; var Salary; run; a.four b.five c.six d.seven

Correct answer: d SAS Enterprise Guide 5.1 creates SAS Report output by default; you can change the default output format and select additional output formats by selecting Tools, Options, Results, Results General. Other result formats that are available in SAS Enterprise Guide 5.1 include HTML, PDF, RTF, and Text or LISTING output. In the windowing environment, SAS 9.3 displays HTML output in the Results Viewer by default. You can choose to have SAS display LISTING output in addition to or instead of HTML output. To change the result format, select Tools, Options, Preferences, and click the Results tab.

10.Which of the following is a true statement about SAS output? a.SAS Enterprise Guide 5.1 displays text or LISTING output by default. b.SAS Enterprise Guide 5.1 displays HTML output by default. c.SAS 9.3 in the windowing environment displays LISTING output by default. d.SAS 9.3 in the windowing environment displays HTML output by default.

Correct answer: b The WHERE statement subsets the data so that the report displays only the observations in which the value of Country is AU. The input data set must be sorted by Gender, the variable specified in the BY statement. The label Annual Salary will not be displayed because the LABEL option is not included in the PROC PRINT statement.

10.Which statement about this program is true? proc print data=orion.sales; var Employee_ID Salary; where Country='AU'; by Gender; label Salary='Annual Salary'; run; a.This program will run correctly only if orion.sales is sorted in ascending order by Country. b.The PROC PRINT report displays only the observations in which the value of Country is AU. c.Annual Salary will be displayed at the top of the Salary column.

Correct answer: b To start, the program closes all destinations and opens only the CSVALL destination. At the end, the program closes the CSVALL destination. There is now no open destination to send the output to. SAS issues a warning in the log but does not display output for the PROC PRINT step.

100. Suppose you submit the program shown below. What happens if you then submit a PROC PRINT step? ods _all_ close; ods csvall file='c:\ctry.csv'; proc freq data=orion.sales; tables Country; run; ods csvall close; a.The PROC PRINT output is displayed in the default window. b.The PROC PRINT output is not displayed and a warning is written to the log indicating that there are no active destinations. c.The PROC PRINT output is appended to the PROC FREQ output in the file ctry.csv.

Correct answer: a The descriptor portion contains general properties, such as the data set name and number of observations. It also contains the variable properties, including the name, type, and length of variables. The data portion contains the data, or variable values.

11.In which portion of a SAS data set are the following found? -the name of the data set -the type of the variable Salary -the creation date of the data set a.descriptor portion b.data portion

Correct answer: b Month is a numeric variable, and the default length of numeric variables is 8 bytes.

12.In this PROC CONTENTS output, what is the default length of the variable Month? a.2 bytes b.8 bytes c.16 or 17 bytes d.32,767 bytes

Correct answer: a In a basic LIBNAME statement, you specify the keyword LIBNAME, a valid libref, and then the physical name of the library in quotation marks.

13.Which LIBNAME statement has the correct syntax? a.libname reports 's:\workshop'; b.libname orion s:\workshop; c.libname 3456a 's:\workshop';

Correct answer: b A PROC CONTENTS step prints a list of data sets in a library. To suppress the descriptor portions, you specify the following after the DATA= option and the libref: the _ALL_ keyword, a space, and then the NODS option.

14.Which PROC step successfully prints a list of all data sets in the orion library without printing descriptor portions for the individual data sets? a.proc contents data=orion.nods _all_;run; b.proc contents data=orion._all_ nods;run; c.proc print data=orion._all_ noobs;run; d.proc print data=orion._all_ nods;run;

Correct answer: b Employee_ID has a missing value that is displayed as a period. A missing value is displayed as a period for numeric variables and as a blank for character variables. Also, numeric values are right-justified and character values are left-justified by default.

15.In this data set, what type of variable is Employee_ID? a.character b.numeric c.temporary d.missing

Correct answer: a When you specify a one-level data set name, SAS assumes the library is work and the data set is temporary.

16.What type of data set is the input data set in this PROC PRINT step? proc print data=order_fact; run; a.temporary b.permanent c.There is not enough information to determine the type.

Correct answer: b Numeric values are stored in floating point notation in 8 bytes of storage, allowing a maximum of 16-17 digits.

17.A numeric variable can store numeric values with a maximum of eight digits. a.True b.False

Correct answer: d The base date is January 1, 1960.

18.Which of the following is not true of SAS date values? a.They are numeric. b.They can be positive or negative values. c.They represent the number of days between the day being stored and a base date. d.The base date is January 1, 1900.

correct answer: b. A SAS library is a collection of SAS files that are referenced and stored as a unit.

19.Which statement about SAS libraries is true? a.You refer to a SAS library by a logical name called a libname. b.A SAS library is a collection of one or more SAS files that are referenced and stored as a unit. c.A single SAS library can contain files that are stored in different physical locations. d.At the end of each session, SAS deletes the contents of all SAS libraries.

Correct answer: d All SAS statements must end with a semicolon, but they are free-format. You can begin or end them anywhere, separate steps with line spaces, and optionally end steps with a RUN statement.

2.Which of the following is a SAS syntax requirement? a.Begin each statement in column one. b.Put only one statement on each line. c.Separate each step with a line space. d.End each statement with a semicolon. e.Put a RUN statement after every DATA or PROC step.

Correct answer: c This libref follows all three rules for valid librefs. A libref must have a length of one to eight characters, and must begin with a letter or underscore. The remaining characters must be letters, numbers, or underscores.

20.Which of the following librefs is valid? a. orionstar b. orion/01 c. or_01 d.1_or_a

Correct answer: d Expressions in the WHERE statement are case-sensitive. This WHERE statement returns only those values that contain the exact character string shown, and the position of the substring within the value is not important.

21.Which observation or observations will be selected by the following WHERE statement? where Job_Title contains 'I'; a.observation 1 b.observation 2 c.observation 3 d.observations 1 and 3 e.all observations

Correct answer: d In the output, the observations are sorted in descending order for Postal_Code and, within each postal code, in descending order for Employee_ID. The BY statement must specify the keyword DESCENDING before each variable.

22.Which statement in a PROC SORT step prepares data to be displayed as shown in this output? a. by Postal_Code Employee_ID; b. by descending Postal_Code Employee_ID; c. by Postal_Code descending Employee_ID; d. by descending Postal_Code descending Employee_ID;

Correct answer: c This PROC SORT step has a syntax error: a semicolon in the middle of the PROC SORT statement. If you correct this syntax error, this step sorts orion.staff by Salary in descending order and by Manager_ID in ascending order. The step then creates the temporary data set staff that contains the sorted observations and all variables.

23.Which statement about this PROC SORT step is true? proc sort data=orion.staff; out=work.staff; by descending Salary Manager_ID; run; a.The sorted data set overwrites the input data set. b.The observations are sorted by Salary in descending order, and then by Manager_ID in descending order. c.A semicolon should not appear after the input data set name. d.The sorted data set contains only the variables specified in the BY statement.

Correct answer: d In the WHERE statement, the IN operator enables you to select observations based on several values. You specify values in parentheses and separate by spaces or commas. Character values must be enclosed in quotation marks and must be in the same case as in the data set.

24.Which of the following statements selects from a data set only those observations for which the value of the variable Style is RANCH, SPLIT, or TWOSTORY? a. where Style='RANCH' or 'SPLIT' or 'TWOSTORY'; b. where Style in 'RANCH' or 'SPLIT' or'TWOSTORY'; c. where Style in (RANCH, SPLIT, TWOSTORY); d. where Style in ('RANCH','SPLIT','TWOSTORY');

Correct answer: d All of the statements shown here select rows in which Amount is less than or equal to $5000 or Rate equals 0.095.

25.Which of the following statements selects rows in which Amount is less than or equal to $5,000 or Rate equals 0.095? a. where Amount<=5000 or Rate=0.095; b. where Amount le 5000 or Rate=0.095; c. where Amount<=5000 or Rate eq 0.095; d. all of the above

Correct answer: a The TITLE statement in the last PROC PRINT step changes the first title line and cancels all previously specified titles with line numbers higher than one.

26.When you run this code, which title or titles appear in the last PROC PRINT output? title1 'The First Line'; title2 'The Second Line'; proc print data=orion.sales; run; title2 'The Next Line'; proc print data=orion.sales; run; title 'The Top Line'; proc print data=orion.sales; run; a.The Top Line b.The Top LineThe Next Line c.The Top LineThe First LineThe Next Line

Correct answer: d You can group by Gender because Gender is the first variable that the data set is sorted by. You could also group by Gender and then Start_Date because the data set is sorted by these variables in the same order. You cannot use the other BY because the variables are not specified for grouping in the same order that the data set is sorted. statements

28.Which BY statement is valid for this PROC PRINT step? proc sort data=orion.staff out=work.staffsort; by Gender Start_Date; run; proc print data=work.staffsort label; by ________________________; label Start_Date='Start'; run; a. by Start_Date Gender; b. by Start; c. by descending Gender; d. by Gender;

Correct answer: a No titles will appear at the top of the second PROC PRINT report. The null TITLE statement above that statement cancels all previously specified titles.

29.Suppose you already ran the first program, which created a one-page report. Next, you want to run the second program. What will appear at the top of the second report? title1 'RADIX Company'; title3 'DVD Sales'; proc print data=radix.sales; where UnitSold>=30; run; title2 'Best Sales'; title; proc print data=radix.staff; where Sales>25000; run; a.no titles b.RADIX CompanyBest SalesDVD Sales c.RADIX CompanyBest Sales d.RADIX Company

Correct answer: b Feedback: PROC steps are typically used to process SAS data sets (that is, generate reports, graphs, and statistics).

3.Which of the following steps is typically used to generate reports and graphs? a.DATA b.PROC c.REPORT d.RUN

Correct answer: b Character formats must start with a dollar sign followed by a letter or underscore. A format name does not end with a period. The period is a required delimiter when using a format in a FORMAT statement.

30. Which of the following is a valid name for a character format? a.country b.$ctry c.$country. d._country

Correct answer: a- False Formats are not associated with a specific variable until they are applied with a FORMAT statement.

32. You specify the variable to which a format applies when creating it in a PROC FORMAT step. a- True b- False

Correct answer: d The data value in the first observation was displayed without commas, because the format width was not large enough. It contains 10 characters, indicating a format width of 12 with 2 decimal places.

33. Which of the following FORMAT statements was used to create this output? a. format Salary dollar.; b. format Salary dollar12.2; c. format Salary dollar11.2; d. format Salary dollar10.2;

Correct answer: b DATE7. displays a two-digit day, three-letter month abbreviation, and two-digit year. MMDDYY8. displays a two- digit month, day, and year, separated by slashes.

34. Which of the following FORMAT statements was used to create this output? a.format Order_Date date9. Delivery_Date mmddyy8.; b.format Order_Date date7. Delivery_Date mmddyy8.; c.format Order_Date ddmmmyy. Delivery_Date mmddyy8.; d.format Order_Date monyy7. Delivery_Date mmddyy8.;

Correct answer: c Character formats must start with a dollar sign followed by a letter or underscore. Numeric formats must start with a letter or underscore. A format cannot be created with the name of an existing SAS format, so comma is invalid.

35. Which of the following is not a valid user-defined format name? a.$month b.group_a c.comma d._gender

Correct answer: b- False You can only use the < symbol to define a non-inclusive range.

36.You can use either < or > to define a non-inclusive range in a VALUE statement. a- True b- False

Correct answer: a- True The period is a required syntax in a format name within a FORMAT statement.

37. The format name must include a period in the FORMAT statement. a- True b- False

Correct answer: d The data value does not match any of the values listed in the VALUE statement, so PROC PRINT will display the stored value. However, the width of the column is 7, the width of the longest format value, 'Manager', so truncation occurs in the output.

38. Given this $TITLE format, what would be displayed for a value of Sales Rep II? proc format; value $title 'Sales Manager', 'Senior Sales Mgr'='Manager' 'Sales Rep. I', 'Sales Rep. II'='Rep'; run; a.Sales Manager b.Rep c.Sales Rep II d.Sales R

Correct answer: b- False A format affects the way a value is displayed. It does not change the stored value in any way.

39. A format modifies both the stored value and the displayed value. a- True b- False

Correct answer: a A block comment can contain semicolons and unbalanced quotation marks, can appear anywhere, and doesn't need a semicolon at the end.

4.Does this comment contain syntax errors? /* Report created for budget presentation; revised October 15. */ proc print data=work.newloan; run; a.No. The comment is correctly specified. b.Yes. Every comment line must end with a semicolon. c.Yes. The comment text incorrectly begins on line one. d.Yes. The comment contains a semicolon, which causes an error message.

Correct answer: b-False A FORMAT statement is used to apply both SAS and user-defined formats.

40. A FORMAT statement is used only to apply SAS formats. a- True b- False

Correct Answer: c A SET statement reads observations from a SAS data set for further processing in the DATA step.

41.Which statement is used to read a SAS data set in a DATA step? a.DATA statement b.WHERE statement c.SET statement d.assignment statement

Correct answer: b The input data set is listed in the SET statement. The SET statement reads observations from the input data set, orion.sales in this DATA step.

42.What is the name of the input data set in the program below? data work.us; set orion.sales; where Country='US'; run; a.work.us b.orion.sales c.Country d.sales

Correct answer: a The output data set is listed in the DATA statement. The DATA statement provides the name of the SAS data set being created, work.us.

43. What is the name of the output data set in the program below? data work.us; set orion.sales; where Country='US'; run; a.work.us b.orion.sales c.Country d.sales

Correct answer: c The SET statement identifies the input data set, salesinfo, which is stored in the permanent library, sporting. The DATA statement identifies the output data set, salesinfo2, to be created in the permanent library, sporting.

44. Which of the following DATA steps correctly reads the permanent data set salesinfo from the sporting library and creates a new data set named salesinfo2 in the same library? a. data sporting.salesinfo2; set salesinfo; run; b. data salesinfo2; set sporting.salesinfo; run; c. data sporting.salesinfo2; set sporting.salesinfo; run;

Correct answer: b During compilation, SAS creates the program data vector and the descriptor portion of the new data set. SAS creates the first observation during the execution phase.

45. Which of the following is not created during the compilation phase? a.the descriptor portion of the output data set b.the first observation c.the program data vector (PDV)

Correct answer: a At compile time, SAS uses the descriptor portion of the input data set, orion.sales, to create nine variables in the program data vector. The DROP statement sets drop flags for three of the nine variables. SAS writes the six variables without drop flags to the output data set, work.comp.

46. The data set orion.sales contains nine variables. Given this DATA step, how many variables does the descriptor portion of work.comp contain? data work.comp; set orion.sales; drop Gender Salary Birth_Date; run; a.6 b.7 c.9 d.None. This program contains a logic error.

Correct answer: a At compile time, SAS uses the descriptor portion of the input data set, orion.sales, to create nine variables in the program data vector. The KEEP statement sets drop flags for the five variables not listed in the KEEP statement. SAS writes the four variables without drop flags to the output data set, work.comp.

47. The data set orion.sales contains nine variables. Given this DATA step, how many variables does the descriptor portion of work.comp contain? data work.comp; set orion.sales; keep Employee_ID Gender Job_Title Salary; run; a. 4 b. 9 c.13 d. None. This program contains a logic error.

Correct answer: a- Yes All of the variables in the input data set are included in the PDV, and the variables not listed in the KEEP statement are in the PDV with drop flags set. The variables listed in the KEEP statement are the only variables written to the output data set.

48. A KEEP statement in a DATA step omits all variables except Name, Color, and Price from the output data set. Are the omitted variables included in the PDV? a- Yes b- No

Correct answer: b SAS executes the expression on the right side of the assignment statement following normal operator precedence, and the result is assigned to Units. The division occurs first (50/10 is 5), and then the addition occurs (140+5 is 145).

49. What value will be assigned to Units? data work.comp; set work.sales; Units=Total+Bonus/Quantity; run; a.19 b.145 c.3 d.missing

Correct answer: b There is a missing semicolon following the data set name. When this step runs, SAS will interpret the word RUN as an option in the PROC PRINT statement (because of the missing semicolon). As a result, the PROC PRINT step will not execute and an error message will be displayed in the log.

5.What result would you expect from submitting this step? proc print data=work.newsalesemps run; a.an HTML report of the work.newsalesemps data set b.an error message in the log c.a LISTING report of the work.newsalesemps data set d.the creation of the temporary data set work.newsalesemps

Correct answer: a PROC CONTENTS displays the descriptor portion of a data set, and SAS stores permanent labels and formats in the descriptor portion.

50. Which procedure can be used to view the permanent labels and formats stored in a data set? a.PROC CONTENTS b.PROC PRINT c.PROC FORMAT d.PROC UNIVARIATE

Correct answer: d In this SAS/ACCESS LIBNAME statement, you must specify an engine name following the libref. Oracle is the engine name.

51.In this SAS/ACCESS LIBNAME statement, what does oracle represent? libname sports oracle user=edu001 pw=edu001 path=dbmssrv schema=educ; a.libref b.option c.table name d.engine name

Correct answer: b A PROC CONTENTS step prints a list of data sets in a library. To suppress the descriptor portions, you specify the following after the DATA= option and the libref: the _ALL_ keyword, a space, and then the NODS option.

52. Which PROC step successfully prints a list of all data sets in the orionx library without printing descriptor portions for the individual data sets? a.proc contents data=orionx.nods _all_; run; b.proc contents data=orionx._all_ nods; run; c.proc print data=orionx._all_ noobs;run; d.proc print data=orionx._all_ nods;run;

Correct answer: b- False. If SAS has a libref assigned to an Excel workbook, the workbook cannot be opened in Excel. To disassociate a libref, use a LIBNAME statement and specify the libref and the CLEAR option. SAS disconnects from the data source and closes any resources that are associated with that libref's connection.

53. When you use the SAS/ACCESS LIBNAME statement to assign a libref to a Microsoft Excel workbook, you can view the workbook using SAS Explorer or Microsoft Excel. a- True b- False

Correct answer: b- False SAS treats the workbook as a library, and each worksheet as a SAS data set.

54. When you use the SAS/ACCESS LIBNAME statement to assign a libref to a Microsoft Excel workbook, SAS treats each worksheet within the workbook as a library. a- True b- False

Correct answer: c This program creates one Excel workbook named annual that contains two worksheets, and it uses two data sets as input data.

55. What does the program shown here create? libname sales excel 'c:\mydata\annual.xls'; data sales.qtr1_2011; set sasdata.qtr1_2011; run; data sales.qtr2_2011; set sasdata.qtr2_2011; run; a.a data set named sales.qtr1_2011 and a data set named sales.qtr2_2011 b.an Excel workbook named sales.qtr1_2011 and an Excel workbook named sales.qtr2_2011 c.an Excel workbook named annual that contains two worksheets, qtr1_2011 and qtr2_2011 d.an Excel workbook named sales that contains two worksheets, qtr1_2011 and qtr2_2011

Correct Answer: c A SET statement reads observations from a SAS data set for further processing in the DATA step.

56. What statement is used to read an Oracle table in a DATA step? a.DATA statement b.WHERE statement c.SET statement d.assignment statement

d. The DATE9. format is used to display all dates read from a worksheet regardless of how the date was formatted in the worksheet.

58. When a date value is read from a worksheet, it is converted automatically to a SAS date. Which SAS format is used to display the value? a.MMDDYY8. b.MMDDYY10. c.DATE7. d.DATE9.

B The original column headings are stored as labels in the descriptor portion of the new data set. In SAS Enterprise Guide, the column names are also used as variable names, but this is not true in the SAS windowing environment.

59. When a SAS data set is created from a spreadsheet, the spreadsheet column headings are always stored as which of the following? a.variable names b.labels c.formats d.descriptor

Correct answer: a SAS keeps a running total of the number of quotation marks in your code. In the windowing environment, an odd number of quotation marks would cause the program to hang; you would have to stop the program before adding the missing quotation mark and resubmitting the program. In contrast, SAS Enterprise Guide automatically adds wrapper code that programmatically balances quotations marks to prevent your program from hanging.

6.If you submit a program containing unbalanced quotation marks in SAS Enterprise Guide, you can simply correct the error and resubmit the program. a.True b.False

True You can use a WHERE statement or a subsetting IF statement to process a subset of a worksheet because the worksheet is treated as though it were a SAS data set.

60. A WHERE statement or a subsetting IF can be used to subset a Microsoft Excel worksheet. a- True b- False

Correct answer: a-False SAS reinitializes the PDV and then reads the second record from the input data file. It does not reinitialize the input buffer.

61.In the first iteration of this program, SAS does the following: -reads a record from the raw data file into the input buffer -scans the input buffer and copies the values to the PDV -writes the values to the output data set -reinitializes the input buffer -reads the next record from the raw data file data work.profit; infile 'c:\mydata\income.csv' dlm=','; input Amount SalesRep $ Customer $; run; a- True b- False

Correct answer: d SAS expects a space between values in a delimited raw data file. When a file uses any other character to separate data values, you use the DLM= option in the INFILE statement to indicate what the delimiter is. In this raw data file, you specify an asterisk, in quotes, as the delimiter.

62. Which INFILE statement correctly specifies the raw data file shown here? a.infile 'c:\mydata\salestotals.dat'; b.infile 'c:\mydata\salestotals.dat' dlm=*; c.infile 'c:\mydata\salestotals.dat' dlm=','; d.infile 'c:\mydata\salestotals.dat' dlm='*';

Correct answer: a You specify variables in the INPUT statement in the same case and order that you want them to appear in the data set.

63. Which of the following INPUT statements creates the data set shown here, assuming that the DATA step does not contain a LENGTH statement? a.input Customer_ID $ Last_Name $ First_Name $ Total_Sales; b.input customer_id $ last_name $ first_name $ total_sales; c.input Last_Name $ First_Name $ Total_Sales Customer_ID $;

Correct answer: b-False You must use the colon modifier along with an informat to enable SAS to correctly read nonstandard values that might not have the same length in a delimited raw data file.

64. The INPUT statement below correctly reads this space-delimited raw data file. input name $ hired date9. age state $ salary comma10.; a- True b- False

Correct answer: b Unless otherwise directed, SAS creates variables with a length of 8 bytes.

65. By default, SAS creates character variables with a length of _____ bytes for list input. a.6 b.8 c.10 d.12

Correct Answer: c A character variable with a length of 8 bytes can have values of up to 8 characters and can hold any value: letters, numerals, blanks, and special characters. A numeric variable with a length of 8 bytes can have more than 8 digits.

66. Which of the following values can SAS store in a character variable that has a length of 8 bytes? a.Sales Manager b.Regional Manager c.12036578 d.$123,293.50 e.06/15/2008c

Correct answer: b-False SAS determines variables attributes the first time it encounters a variable, so for the LENGTH statement to define the length of variables in the output data set, it needs to precede the INPUT statement in the DATA step.

67. To explicitly define the length of a variable read from a raw data file, you use a LENGTH statement after the INPUT statement in a DATA step. a- True b- False

Correct answer: b SAS expects a space between values in a delimited raw data file. When a file uses any other character to separate data values, you use the DLM= option in the INFILE statement to indicate what the delimiter is. In this raw data file, you specify an asterisk, in quotes, as the delimiter.

68. Which INFILE statement correctly specifies the raw data file shown here? Partial sales.dat a.infile 'c:\mydata\sales.dat'; b.infile 'c:\mydata\sales.dat' dsd dlm='*'; c.infile 'c:\mydata\sales.dat' dlm=*; d.infile 'c:\mydata\sales.dat' dlm='*';

Correct answer: a You use the DATALINES statement to read in-stream data, which is lines of data that you enter directly into your SAS program, rather than data that is stored in an external file. A DATALINES statement must be the last statement in the DATA step, except for the RUN statement, and it must immediately precede the lines of data.

69. Which of the following statements specifies in-stream data, or the lines of data that you enter directly in a DATA step? a.DATALINES b.INFILE c.INPUT d.INSTREAM

a- True A SAS name literal is a string within quotation marks, followed by the letter n. SAS name literals permit special characters in data set names.

7. A SAS name literal is a string that contains one or more special characters, enclosed in quotation marks, followed by the letter n. a- True b- False

Correct answer: b The log will indicate that SAS assumed that the keyword PROC was misspelled, corrected it temporarily, and executed the PROC step.

7.What happens if you submit the following program? porc print data=work.newsalesemps; run; a.SAS does not execute the step. SAS assumes that the keyword PROC is misspelled and executes the PROC PRINT step

Correct answer: b To display temporary labels in PROC PRINT output, you must specify either the SPLIT= option or the LABEL option in the PROC PRINT statement.

7.Which program creates the output shown here? a. proc print data=orion.staff; var Employee_ID Emp_Hire_Date; label Employee_ID='Emp ID' 'Employee_Hire Date'; run; b. proc print data=orion.staff split='+'; var Employee_ID Emp_Hire_Date; label Employee_ID='Emp ID' Emp_Hire_Date='Employee+Hire Date'; run;

Correct answer: d You cannot use the WHERE statement to subset observations that are read from a raw data file.

70. Which of the following statements cannot be used in a DATA step that reads a raw data file as input? a.KEEP b.IF c.FORMAT d.WHERE

Correct answer: c. In this DATA step, if the value of PayClass is Contract, the observation doesn't meet either of the conditions for PayClass. Therefore, the ELSE statement with no condition assigns the JobRate value to Amt. The DO group doesn't apply in this case.

71.Based on this program and the observation shown in the PDV, what variable's value will be assigned to Amount? data payroll; set salaries; if PayClass='Monthly' then Amount=Salary; else if PayClass='Hourly' then do; Amount=HrlyWage*Hrs; if Hrs>40 then Msg='CHECK TIMECARD'; end; else Amount=JobRate; run; a.not specified b.HrlyWage*Hrs c.JobRate d.Salary

Correct answer: b The MONTH function extracts the month from a SAS date and returns a number from 1 to 12.

72.Which of the following SAS functions returns a number from 1 to 12? a.YEAR(SAS-date) b.MONTH(SAS-date) c.WEEKDAY(SAS-date) d.TODAY(SAS-date)

Correct answer: b The DATA step reads the nine existing variables, adds the new variable Compensation, and drops Gender, Salary, and Country at output time. The variables in the DROP statement never appear in the new data set.

73.The data set orion.sales contains nine variables. Given this DATA step, how many variables does the descriptor portion of work.comp contain? data work.comp; set orion.sales; drop Gender Salary Country; Compensation=sum(Salary,Bonus); run; a.6 b.7 c.10 d.None. This program contains a logic error.

Correct answer: b Adding an ELSE statement without a condition ensures that all observations have a nonmissing value for Bonus, even if they don't meet any stated condition.

74.Which DATA step ensures that all observations are assigned a nonmissing value for Bonus? a- data work.bonus; set orion.sales; if Country='US' then Bonus=500; else if Country='AU' then Bonus=300; run; b- data work.bonus; set orion.sales; if Country='US' then Bonus=500; else Bonus=300; run;

Correct answer: a The length of a new variable is determined by the first reference in the DATA step. In this case, the length of Type is determined by the value Fixed. Although a LENGTH statement is included, it is in the wrong place. It should appear before any other reference to the variable in the DATA step. The LENGTH statement cannot change the length of an existing variable.

75.In the DATA step below, what is the length of the new variable, Type? data orion.newloan; set orion.records; TotalPaid=sum(TotLoan+Interest); if Code='1' then Type='Fixed'; else Type='Variable'; length Type $ 10; run; a.5 b.8 c.10 d.It depends on the first value of Type in orion.records.

Correct answer: c The SUM function ignores missing values, so the value of Benefit is the sum of Ins (800) and Health_Award (a missing value), which equals 800.

76.In the program below, what is the value of Benefit for the observation shown? data work.total; set payroll.june; Benefit=sum(Ins,Health_Award); run; a.a missing value b.55050 c.800 d.0

Correct Answer: a Remember that numeric functions require appropriate numeric arguments. Last_Name is a character variable. Except for the TODAY() function, numeric functions must specify arguments including numeric constants, numeric variables, or arithmetic expressions in parentheses following the function keyword. The TODAY() function doesn't require an argument.

77.Which of these statements does not correctly specify a SAS function? a.Deadline=sum(TimeSpent, Last_Name); b.GreatDay=today(); c.FingersToes=sum(10,10); d.BirthdayYear=year('12dec1987'd);

Correct answer: a- yes Variables in the DROP statement are dropped during output, so they're available for calculations in the DATA step, even if they follow the statements that reference them.

78.Given what you know about how SAS processes the DROP and KEEP statements, would these two DATA steps create the same data set? data work.subset1; set orion.sales; drop Salary; Bonus=500; Compensation=sum(Salary,Bonus); BonusMonth=month(Hire_Date); run; data work.subset1; set orion.sales; Bonus=500; Compensation=sum(Salary,Bonus); BonusMonth=month(Hire_Date); drop Salary; run; a- Yes b- No

Correct answer: d In the DATA step, the first reference to a variable determines its length. The first reference to a new variable can be in a LENGTH statement, an assignment statement, or another statement such as an INPUT statement. After a variable has been referenced in your program, the length of the variable's first value does not affect the length of the variable.

79.Which of the following determines the length of a new variable at compile time? a.INPUT statement b.assignment statement c.LENGTH statement d.all of the above

Correct answer: b Without a RUN statement (or a following DATA or PROC step), the DATA step doesn't execute. Unbalanced quotation marks can also cause the DATA step running message if relatively little code follows the unbalanced quotation mark. The other three problems above generate errors in the Log window.

8.Suppose you submit a short, simple DATA step. If the active window displays the message DATA step running for a long time, what probably happened? a.You misspelled a keyword. b.You forgot to end the DATA step with a RUN statement. c.You specified an invalid data set option. d.Some data values were not appropriate for the SAS statements that you specified.

Correct answer: a- True Only one executable statement is allowed in IF-THEN and ELSE statements. Multiple executable statements are allowed in IF-THEN DO/ELSE DO statements. Each DO group can contain multiple statements that apply to the expression.

80.Use a DO group in a DATA step when you want to execute multiple statements for a true IF-THEN expression. a- True b- False

Correct answer: e All of these statements about merging SAS data sets by using the DATA step are true.

81.Which of the following statements is true about merging SAS data sets by using the DATA step? a.Merging combines observations from two or more data sets into a single observation in new data set. b.SAS can merge data sets based on the position of observations in the original data set or by the values of one or more common variables. c.Match-merging is merging by values of one or more common variables. d.To match-merge data sets, all input data sets must be sorted or indexed on the BY variable or variables. e.all of the above

Correct answer: b You list the data sets that you want to concatenate in the SET statement, in the same order that you want to concatenate them. You list both data sets in one SET statement.

82.Which of the following programs concatenates the data sets sales and products, in that order? a. data newsales; set products sales; run; b. data newsales; set sales products; run; c. data newsales; set sales; set products; run;

Correct answer: c By default, the output data set of a DATA step that includes a MERGE statement and a BY statement includes all of the observations from all of the input data sets that are listed in the MERGE statement.

83.If you run this DATA step, what observations does the data set bonuses contain? data bonuses; merge managers staff; by EmpID; run; a.all of the observations from managers, and only those observations from staff with matching values for EmpID b.all of the observations from staff, and only those observations from managers with matching values for EmpID c.all observations from staff and all observations from managers, whether or not they have matching values d.only those observations from staff and managers with matching values for EmpID

Correct answer: a The concatenated data sets are read sequentially, in the order in which they are listed in the SET statement. The second observation in Reps does not contain a value for Sale, so a missing value appears for this variable.

84.If you concatenate the data sets below in the order shown, what is the value of Sale in observation 2 of the new data set? a.missing b.$30,000 c.$40,000 d.You cannot concatenate these data sets.

Correct answer: c The two input data sets are not sorted by values of the BY variable, so the DATA step produces errors and stops processing.

85.What happens if you submit the following program to merge donors1 and donors2, shown below? data merged; merge donors1 donors2; by ID; run; a.The merged data set contains some missing values because not all observations have matchingobservations in the other data set. b.The merged data set contains eight observations. c.The DATA step produces errors.

Correct answer: b To combine two variables, you can use the RENAME= option to rename a variable for processing. You specify the RENAME= option next to the name of the data set that contains the variable that you want to rename.

86.

Correct answer: b The RENAME= option after data set returns_jan has an extra set of parentheses. This is the correct code: (rename=(ID=CustID Return=Item)).

87.What is the syntax error in this DATA step? data returns_qtr1; set returns_jan(rename=(ID=CustID) (Return=Item)) returns_feb(rename=(Dt=Date)) returns_mar; run; a.You cannot specify more than two data sets in the SET statement. b.There are too many sets of parentheses in the RENAME= option. c.You cannot specify multiple variables in the RENAME= option. d.The BY statement is missing.

Correct answer: c Both of the data sets contribute observations on the second iteration of the DATA step, so the values of both IN= variables are 1. The values of the IN= variables are always either 0 or 1, depending on whether the data set contributes an observation to the output data set on that iteration.

88.

Correct answer: a The subsetting IF statement selects all observations from staff that have no match in managers.

89.If you run this DATA step, what observations does the data set bonuses contain? data bonuses; merge managers (in=M) staff (in=S); by EmpID; if M=0 and S=1; run; a.only the observations from staff that have no match in managers b.only the observations from managers that have no match in staff c.all observations from both managers and staff, whether or not they match d.no observations

Correct answer: c All SAS programs generate log messages. This program creates a PROC PRINT report and moves the Results window to the front. The output appears in the corresponding window (the Output window for LISTING output, or the Results Viewer or browser window for HTML output).

9.Suppose that this program contains no errors. What happens when you submit the program in the SAS windowing environment? proc print data=work.sales; run; a.Messages appear in the Log window, and the Explorer window moves to the front. b.Any HTML output appears in the Output window or a browser window, and any LISTING output appears in the Results Viewer window. c.Any HTML output appears in the Results Viewer window or a browser window, and any LISTING output appears in the Output window.

Correct answer: a The SAS data sets first and second have a one-to-one matching relationship. Each observation in first match one and only one observation in second.

90.

Correct answer: b PROC MEANS and PROC UNIVARIATE analyze numeric variables. PROC PRINT is more useful for producing a report of invalid values, with a WHERE statement to specify conditions. PROC FREQ identifies duplicate values by default in the Frequency column of the report.

91. Which of these procedures produces output that is most useful for detecting duplicate values? a.PROC PRINT b.PROC FREQ c.PROC MEANS d.PROC UNIVARIATE

Correct answer: c Only PROC UNIVARIATE provides observation numbers for data outliers.

92. Which of these programs is most useful for determining the exact observation that contains a numeric variable with an extreme value? a. proc print data=sales.totals; var ProdNum Sales Region; run; b. proc freq data=sales.totals; tables ProdNum Sales Region; run; c. proc univariate data=sales.totals; run;

Correct answer: a PROC PRINT is the only one of these procedures that displays the observations themselves. The other three procedures produce summary reports that display descriptive statistics.

93. A PROC FREQ analysis identified invalid and missing values in a data set. Which of these procedures will display the observations that contain invalid or missing values? a.PROC PRINT b.PROC FREQ c.PROC MEANS d.PROC UNIVARIATE

Correct answer: b To display a table showing the levels of all variables, you specify the NLEVELS option in the PROC FREQ statement. To suppress the cumulative frequency and cumulative percent that appear in a one-way frequency table by default, you specify the NOCUM option in the TABLES statement. You must use a slash before any options in a TABLES statement.

94.

Correct Answer: False By default, a PROC MEANS step that has no CLASS statement produces all of these statistics except for N Obs.

95. This PROC MEANS step creates all of the statistics listed below. -minimum and maximum -the total number of observations that PROC MEANS processes for each subgroup (N Obs) -mean and standard deviation -the number of nonmissing values (N) a- True b- False

Correct answer: d This output does not display the default statistics, so you need to specify the statistics keywords RANGE and MEAN. To suppress the N Obs column that the CLASS statement creates, you must include the NONOBS option. Specifying MAXDEC=1 ensures that statistics are displayed with one decimal place.

96.

Correct Answer: a In PROC UNIVARIATE, you use the NEXTROBS= option to specify the number of extreme observations. In PROC FREQ, you can use the NLEVELS option to display a table with the number of distinct variable values. You use the NOPRINT option in the TABLES statement to suppress individual frequency tables. To display only the number of levels for all variables, you can use _ALL_, along with the NOPRINT option in the TABLES statement.

97. Which option lets you specify the number of extreme observations displayed by PROC UNIVARIATE? a.NEXTROBS= b.NLEVELS c.NOPRINT d._ALL_

Correct answer: b CSVALL does not include any style information. MSOFFICE2K keeps the style information, including spanning headers. EXCELXP keeps the style information, and each procedure is a separate sheet.

98. Which destination creates a file that keeps the style information and opens in multiple worksheets in an Excel workbook? a.CSVALL b.EXCELXP c.MSOFFICE2K d.none of the above

Correct Answer: D SAS uses a default style definition that varies by the destination. By placing the STYLE= option in the ODS statement, you can specify a style for many, but not all, destinations. A style definition specifies how output is presented but does not specify a file format.

99. Which statement about style definitions is true? a.The STYLE= option affects the display in all destinations. b.You can use the STYLE= option in an ODS statement or in a PROC statement. c.A style definition specifies colors, fonts, and a file format for an external file. d.If you do not specify a style definition, SAS uses a default style definition that varies by the destination.


Ensembles d'études connexes

igneous petrology unit of geoscience 201

View Set

Fall Fill-in-the-Blank Sentences

View Set

Chapter 13 Preterm and Postterm Newborns

View Set

Ch 1. LearningCurve: Numbers and Measurements

View Set