Paper3

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Paper3 as PDF for free.

More details

  • Words: 7,058
  • Pages: 32
Quiz Score:

0%

You answered 0 out of 50 questions correctly. To see any answer, scroll down or click a question in the grid below. When you select links on this page, the information appears in the original browser window. Question #

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

Correct / Incorrect

1.

A raw data file is listed below. 1---+----10---+----20---+--01/05/1989 Frank 11 12/25/1987 June 13 01/05/1991 Sally 9

The following SAS program is submitted using this file as input: data work.family; infile 'file-specification'; input @1 date_of_birth mmddyy10. @15 first_name $5. @25 age 3; run; proc print data=work.family noobs; run;

The following output is generated for the Work.Family data set: Date_of_birth First_name Age 10597 Frank

.

10220 June

.

11327 Sally

.

Which of the following statements is true regarding the Work.Family output? a. The output has the expected data values. b. The output does not have the expected data values due to an invalid data set name. c. The output does not have the expected data values due to an invalid informat for Age only. d. The output does not have the expected data values due to invalid informats for both Age and Date_of_birth. Correct answer: c Your answer: The output for Work.Family does not have the expected data values. The values for the variable Age are missing because the program contains an invalid informat for Age. The informat for reading standard numeric data is w.d, so the correct informat for Age is 3.. The informat for Date_of_birth, mmddyy10., is correct. 2.

The following SAS program is submitted: data employees; infile 'file-specification'; input @1 name $10. @15 date date9 @25 department $; run;

How many numeric variables are created? a. 0 b. 1 c. 2 d. 3 Correct answer: Your answer:

c

and Department are created as character variables because they both use the $w. informat. If the second line of the INPUT statement was Name

@15 date date9., then the program would create one numeric variable named Date. However, the period is missing from the informat date9..

Therefore, SAS interprets the line as list input rather than formatted input, and creates two numeric variables: Date and Date9. 3.

What is the function of the FILENAME statement in SAS? a. It associates a file reference with an external file. b. It associates a library reference with an external file. c. It associates a file reference with a relational database. d. It associates a library reference with a relational database. Correct answer: a Your answer: The FILENAME statement associates a file reference with an external file. The LIBNAME statement associates a library reference with a SAS data library. The LIBNAME statement can also associate a library reference with a relational database if you have the appropriate SAS/ACCESS products licensed for the relational database that you need to access.

4.

A raw data file is listed below. 1---+----10---+----20---+--Jose,47,210 Sue,,108

The following SAS program is submitted using this file as input: data employeestats; ; input name $ age weight; run;

The following output is desired: name age weight Jose

47

210

Sue

.

108

Which of the following INFILE statements completes the program and accesses the data correctly? a. b. c. d.

infile 'file-specification' pad; infile 'file-specification' dsd; infile 'file-specification' missover; infile 'file-specification' dlm=',';

Correct answer: Your answer:

b

The correct INFILE statement uses the DSD option to read the data with commas as delimiters and uses two consecutive commas to indicate a missing value. The 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, but by default consecutive delimiters are treated as one delimiter rather than as an indication of a missing value. 5.

A raw data file is listed below. 1---+----10---+----20---+--RANCH,1250,10MAR2004 SPLIT,1190,10/20/2004 CONDO,1400,17JUN2004 TWOSTORY,1810,12/31/2004 RANCH,1500,20JAN2004 SPLIT,1615,08/19/2004

The following SAS program is submitted using this file as input: data work.condo_ranch; infile 'file-specification' dsd; input style $ @; if style = 'CONDO' or style = 'RANCH' then input sqfeet saledate : date9.; else input sqfeet saledate : mmddyy10.; run;

How many observations does the Work.Condo_ranch data set contain? a. 0 b. 3 c. 5 d. 6 Correct answer: Your answer:

d

There are 6 observations in the Work.Condo_ranch data set. The trailing @ in the first INPUT statement holds the record in the input buffer and allows the next INPUT statement that is executed to continue reading from the same record. The program uses IF-THEN/ELSE conditional logic to execute either the second or third INPUT statement conditionally based on the value of Style. Because of the trailing @ in the first INPUT

statement, the second or third INPUT statement reads from the same record as the first INPUT statement. Therefore, each line in the raw data file is read once, which creates a total of 6 observations in the output data set. 6.

A raw data file is listed below. 1---+----10---+----20---+----30---+----40---+----50 TWOSTORY 1040 2 1SANDERS ROAD $55,850 CONDO 2150 4 2.5JEANS AVENUE $127,150

The following program is submitted using this file as input: data work.houses; infile 'file-specification'; run;

Which one of the following INPUT statements reads the raw data file correctly? a. input @1

b.

c.

d.

style $8. +1 sqfeet 4. +1 bedrooms 1. @20 baths 3. street 16. @40 price dollar8; input @1 style $8 +1 sqfeet 4. +1 bedrooms 1. @20 baths 3. street $16 @40 price dollar8.; input @1 style $8. +1 sqfeet 4. +1 bedrooms 1. @20 baths 3. street $16. @40 price dollar8.; input @1 style $8. +1 sqfeet 4. +1 bedrooms 1. @20 baths 3 street 16. @40 price dollar8.;

Correct answer: Your answer:

c

To read formatted input, an INPUT statement requires valid informats. A valid informat always contains a period. The correct INPUT statement creates 2 character variables (Style and Street) and 4 numeric variables (Sqfeet, Bedrooms, Baths, and Price).

7.

The following SAS program is submitted: data both; set M F(in = INF); if INF then gen = 'F'; else gen = 'M'; by name; run;

The SAS data sets Work.M and Work.F are each sorted by the variable Name. The data set Work.M contains 10 observations, and the data set Work.F contains 9 observations. How many observations does the Work.Both data set contain? a. 0 b. 9 c. 10 d. 19 Correct answer: Your answer:

d

The Work.Both data set contains 19 observations. The valid SET statement contains two input data sets, which causes the input data sets to be concatenated. The IN= data set option creates an indicator variable that is used to conditionally assign a value to the variable Gen. The variable Inf indicates whether Work.F contributed data to the current observation. When Work.F contributes to the current observation, the IF statement is true and the value of Gen is set to F. Otherwise, the IF statement is false and the value of Gen is set to M. 8.

The following SAS program is submitted: data test(drop=age); set sashelp.class(keep=name age gender height weight); drop=gender; newage=age+1; run;

Sashelp.Class contains 5 variables. What is the result? a. No variables are written to the data set Work.Test. b. 4 variables are written to the data set Work.Test. c. 5 variables are written to the data set Work.Test. d. 6 variables are written to the data set Work.Test. Correct answer: d Your answer: The Work.Test data set contains 6 variables: Name, Gender, Height,

Weight, Drop,

and Newage. The KEEP= option in the SET statement reads 5 variables from the input data set. The variable Age is read from the input data set, but it is dropped from the output data set by the DROP= data set option. There are also two new variables created in the DATA step. 9.

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; proc print data=sales; run;

The SAS data set Sasdata.Salesdata has 10 observations. Which one of the following answers explains why a report fails to generate? a. The DATA step fails to execute. b. The SAS data set Sales does not exist. c. The SAS data set Sales has no observations. d. The PRINT procedure statement syntax is incorrect. Correct answer: b Your answer: The LIBNAME statement creates a permanent data library named Sasdata. The DATA statement indicates that the new data set Sales will be stored in the permanent library Sasdata. The PRINT procedure references a temporary SAS data set, Sales, which is stored in the Work library. At the beginning of the SAS session, Work.Sales does not exist.

10. The SAS data set Sasdata.Two is listed below. Sasdata.Two x y 5 2 5 4 3 6

The following SAS program is submitted: data sasuser.one one; set sasdata.two; output one;

run;

What is the result? a. The data set Sasuser.One has 0 observations and the data set One has 0 observations. b. The data set Sasuser.One has 0 observations and the data set One has 3 observations. c. The data set Sasuser.One has 3 observations and the data set One has 0 observations. d. The data set Sasuser.One has 3 observations and the data set One has 3 observations. Correct answer: b Your answer: There are 2 output data sets listed in the DATA statement: the permanent data set Sasuser.One and the temporary data set One. The SET statement reads 3 observations from Work.Two. The OUTPUT statement is used to explicitly output the 3 observations to the Work.One data set. When the OUTPUT statement is used, it turns off automatic output in the DATA step, so any data set that is listed in the DATA statement but not in the OUTPUT statement will not have any observations written to it. Because there is no explicit OUTPUT statement for Sasuser.One, the data step creates Sasuser.One but it has 0 observations. 11. The following SAS program is submitted: data work.new; y=10; z=05; x=12; date=mdy(x,y,z); run;

What is the value of the Date variable? a. a character string with the value 12/10/05 b. a character string with the value 10Dec2005 c. a numeric value of 16780, which represents the SAS date value for December 10, 2005 d. a numeric value of 121005, which represents the SAS date value for December 10, 2005 Correct answer: c Your answer: The MDY function creates a numeric value that represents a SAS date value. The arguments in the MDY function must be numeric, and they must represent the values for the month, day, and year (in that order). SAS date values are calculated as the number of days from January 1, 1960, to the given date. Therefore, the numeric value 16780 represents the SAS

date value for December 10, 2005. 12. The 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 2005, and the variable Sales_Date contains a SAS date value for each of the 12 months. How many of the original 12 observations in Work.Sales_info are written to the Work.Report data set? a. 2 b. 3 c. 6 d. 9 Correct answer: Your answer:

c

The QTR function extracts a value from 1 to 4 from a SAS date value. This value indicates the quarter of the year in which the date falls. The quarters are based on a calendar year starting with January. The subsetting IF statement continues to process only when the observation has a Sales_date value that falls in the last 2 quarters of the year. Because the input data set contains one observation for each month in the year 2005, there are 6 observations written to Work.Report. 13. The following SAS program is submitted: data _null_; set old(keep=sales1 sales2); file 'file-specification'; put sales1 sales2; run;

What is the result? a. A raw data file is created with no delimiter separating the fields. b. A raw data file is created with a space delimiter separating the fields. c. A raw data file is created with a comma delimiter separating the fields. d. No raw data file is created. The DATA step fails execution because no delimiter is specified. Correct answer: b Your answer:

The FILE statement specifies the output file for the DATA step. The PUT statement describes the lines to write to the raw data file. In this case, the PUT statement is used with list input, so the fields in the output are delimited by a blank space. 14. The following SAS program is submitted: data _null_; set old = last; put sales1 sales2; if last then put 'This is the end of the data set'; run; Which of the following options creates the variable Last?

a. END b. EOF c. PTOBS d. TOTOBS Correct answer: Your answer:

a

The END= option creates and names a temporary variable whose value is 1 when the DATA step is processing the last observation (otherwise the value is 0). PTOBS, EOF, and TOTOBS are not valid SAS options. 15. The SAS data set One is listed below. One X Y

Z

1 A 27 1 A 33 1 B 45 2 A 52 2 B 69 3 B 70 4 A 82 4 C 91

The following SAS program is submitted: data two; set one; by x; if first.x;

run; proc print data=two noobs; run;

Which of the following reports is the result? a. X Y Z 1

A 27

2

A 52

3

B 70

4

A 82

b. X Y Z 1

A 27

1

B 45

2

A 52

2

B 69

3

B 70

4

A 82

4

C 91

c. X Y Z 1

B 45

2

B 69

3

B 70

4

C 91

d. No report is produced. The PRINT procedure fails because the data set Two is not created in the DATA step. Correct answer: a Your answer: is a temporary variable that is automatically created to identify the beginning of each BY group. First.X is not included in the output data set Two. The subsetting IF statement in this program is true for the first observation of each BY group. Therefore, the data set Two contains one observation for the first instance of each value of X in One. First.X

16. The following SAS program is submitted:

libname sasdata 'SAS-data-library'; libname labdata 'SAS-data-library'; data labdata.boston labdata.dallas(drop=city dest equipment);

set sasdata.cities(keep=orig dest city price equipment); if dest='BOS' then output labdata.boston; else if dest='DFW' then output labdata.dallas; run;

Which variables are output to both data sets? a. Price and Orig only b. City and Equipment only c. City, Price, and Equipment only d. City, Price, Orig, and Equipment only Correct answer: a Your answer: The DROP= data set option specifies which variables are dropped when the Labdata.Dallas data set is created. If neither the DROP= data set option nor the KEEP= data set option is used, then all of the variables that are read from the input data set are included in the output data set. The KEEP= data set option in the SET statement specifies which variables to read from the input data set. Therefore, the variables that both output data sets contain are the variables that are listed in the KEEP= option in the SET statement and are not listed in the DROP= data set option in the DATA statement. 17. The following SAS program is submitted:

proc contents data=sasuser.airplanes; run;

What is produced as output? a. the code that created the data set Sasuser.Airplanes b. the data portion only of the data set Sasuser.Airplanes c. the descriptor portion only of the data set Sasuser.Airplanes d. the data and descriptor portions of the data set Sasuser.Airplanes Correct answer: c Your answer: The CONTENTS procedure cannot produce the code that created the data set Sasuser.Airplanes. PROC CONTENTS displays only the descriptor portion of the data set. To see a listing of the data portion of the data set, you can use the PRINT procedure or the REPORT procedure. 18. Which SAS procedure displays a listing of the observations in the data portion of a SAS data set?

a. FSLIST b. REPORT c. TABULATE d. CONTENTS Correct answer: Your answer:

b

The REPORT procedure displays a listing of the observations in the data portion of the SAS data set. The FSLIST procedure displays the contents of an external file. The TABULATE procedure displays a tabular report of the observations in the data portion of the SAS data set. The CONTENTS procedure displays the descriptor portion of the SAS data set. 19. The 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; run;

Which of the following statements completes the program and sorts the Work.Test data set by Name in descending order? a. by desc name; b. by name desc; c. by descending name; d. by name descending; Correct answer: c Your answer: The SORT procedure orders SAS data set observations by the values of one or more character or numeric variables that are listed in the BY statement. The SORT procedure arranges the data in ascending order by default. To sort in descending order, the keyword DESCENDING must be included in the BY statement before the sort variable. The keyword DESCENDING cannot be abbreviated in the BY statement. 20. The following SAS program is submitted: proc sort data=payroll; by EmployeeIDNumber; run;

How are the observations sorted?

a. Payroll is re-created in sorted order by EmployeeIDNumber. b. Payroll is stored in original order, and a new data set Payroll is created in sorted order by EmployeeIDNumber. c. Payroll is stored in original order, and a new data set Payrollsorted is created in sorted order by EmployeeIDNumber. d. Payroll is re-created in sorted order by EmployeeIDNumber, and a new data set Payroll is created in sorted order by EmployeeIDNumber. Correct answer: a Your answer: The SORT procedure orders SAS data set observations by the values of one or more character or numeric variables that are listed in the BY statement. The SORT procedure re-creates and replaces the original data with the sorted version of the data if the OUT= option is not used. If the OUT= data set is used, a new data set is created to hold the sorted data, and the original data remains unchanged. 21. Which one of the following SAS programs creates a variable named City with a value of Chicago? a. data work.airports;

b.

c.

d.

AirportCode='ord'; if AirportCode='ORD' City='Chicago'; run; data work.airports; AirportCode='ORD'; if AirportCode='ORD' City='Chicago'; run; data work.airports; AirportCode='ORD'; if AirportCode='ORD' then City='Chicago'; run; data work.airports; AirportCode='ORD'; if AirportCode='ORD'; then City='Chicago'; run;

Correct answer: Your answer:

c

This DATA step uses an IF-THEN statement to conditionally assign the value Chicago to the variable City. The correct syntax for an IF-THEN statement is IF expression THEN statement. 22. The SAS data set Employees is listed below.

Employees Name Salary Patel

60000

Payne

50000

Ellis

55000

Liu

45000

The following SAS program is submitted: proc print data=employees; where name ? 'e'; run;

What is the result? a. No observations are written to the report. b. The observation for Ellis only is written to the report. c. The observations for Patel and Payne only are written to the report. d. The observations for Patel, Payne, and Ellis only are written to the report. Correct answer: c Your answer: Two observations are written to the report: one for Patel, and one for Payne. The WHERE statement uses ?, which is a mnemonic equivalent for the CONTAINS operator. The CONTAINS operator searched for a specific set of characters within the values of a character variable. The position of the string does not matter, but the case does. Because Ellis contains an uppercase E, it is not included in the report. 23. The following SAS program is submitted: data result; lname="o'reiley"; ; run;

Which statement completes the program and creates the variable X with a value of O'Reiley? a. x=propcase(lname); b. x=propcase(lname,"'"); c. x=upcase(lname); d. x=upcase(lname,"'"); Correct answer: b

Your answer: The PROPCASE function converts all words in an argument to proper case. The PROPCASE function uses a default list of delimiters if none are specified. The delimiter required to correctly convert the value o'reiley to proper case is a single quotation mark. Because the single quotation mark is not one of the default delimiters, it must be listed as the second argument in the function. The UPCASE function converts all letters in the argument to uppercase. There is only one argument for the UPCASE function. 24. The following SAS program is submitted:

data work.count; if OriginalAmount= . then OriginalAmount=100; AdditionalItems=100; OriginalAmount= .; TotalCount=(OriginalAmount+AdditionalItems)+0; run; What is the value of the Totalcount variable in the output data

set?

a. 0 b. 100 c. 200 d. . (missing numeric value) Correct answer: d Your answer: Arithmetic operators do not ignore missing values. The result of adding a missing value to an expression with an arithmetic operator is a missing value. In this program, the value of OriginalAmount is missing at the beginning of the DATA step. The IF-THEN logic changes the value of OriginalAmount to >100. Then, the assignment statement for OriginalAmount changes the value to missing. Therefore, OriginalAmount has a missing value when it is used in the expression for the TotalCount assignment statement. 25. Which SAS program renames two variables?

a. set work dept1 b. c. d.

work dept2(rename=(jcode=jobcode) (sal=salary)); set work dept1 work dept2(rename=(jcode=jobcode sal=salary)); set work dept1 work dept2 rename=(jcode=jobcode sal=salary); set work dept1 work dept rename=jcode=jobcode sal=salary;

Correct answer: Your answer:

b

In the RENAME= data set option, you list the old variable name, followed by an equal sign and the new variable name. You enclose the variable names in one set of parentheses, and you enclose the entire RENAME= option in a second set of parentheses. 26. The variable Name in the data set Employee has a format of $CHAR9. The variable Name in the data set Sales has a format of $CHAR15. The following SAS program is submitted: data merged; merge employee sales; by name; format name $CHAR12.; run;

What is the format for the variable Name in the data set Merged? a. $CHAR. b. $CHAR9. c. $CHAR12. d. $CHAR15. Correct answer: Your answer:

c

The FORMAT statement specifies $CHAR12. as the format for the variable Name in the data set Merged. By default, the FORMAT attribute is determined by the data set that is listed first in the MERGE statement. If you use a FORMAT statement in the DATA step, then the FORMAT statement overrides the FORMAT attribute from the first data set that is listed in the MERGE statement. 27. What is true of the sum statement in a SAS DATA step program?

a. It is valid only 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. Correct answer: c Your answer: The sum statement in the DATA step is used to create an accumulator variable. It adds the value of the expression to the accumulator variable and ignores missing values. The value of the accumulator variable is retained from one iteration of the SAS DATA step to the next. The sum statement is valid in any DATA step. 28. What is the correct form of the sum statement in a DATA step? a. sum var1 var2; b. var1 + var2; c. total=var1 + var2; d. total=sum(var1,var2); Correct answer: b Your answer: The sum statement specifies the name of an accumulator variable and adds the result of the expression to that variable. The value is initially set to 0 and is retained. The SUM statement in the PRINT procedure is different from the sum statement in the DATA step. There is also a SUM function that can be used in the DATA step. 29. The following SAS program is submitted: data one; address1='214 London Court'; run; data output; set one; address1=; run;

Which of the following completes the program and changes the word Court to Drive in the value of the variable Address1?

a. tranwrd(address1,'Court','Drive') b. trantab(address1,'Court','Drive') c. translate(address1,'Court','Drive') d. transform(address1,'Court','Drive') Correct answer: a Your answer: The TRANWRD function replaces or removes all occurrences of a word in a character string. The TRANTAB function transcodes a data string by using a translation table. The TRANSLATE function replaces a specific character expression. TRANSFORM is not a valid SAS function. 30. The following SAS program is submitted: data work.test; title="Hitchhiker's Guide to the SAS Language"; word=substr(title,13,5); run; What is the value of the variable Word in the output data set?

a. Guide b. ide t c. s Guid d. Guide to the SAS Language Correct answer: a Your answer: The SUBSTR function in this program returns a 5-character substring of the value of Title, beginning at the 13th character. 31. The following SAS program is submitted: data work.products; Product_Number=5461; Item='1001'; Item_Reference=item||'/'||product_Number; run;

What is the result? a. The variable Item_reference is created with a missing value. b. The variable Item_reference is created with the value 1001/5461. c. The variable Item_reference is created with the value 1001/ 5461. d. The variable Item_reference is not created. The program fails to execute because of errors. Correct answer: c

Your answer: The Item_Reference variable is created as a character variable with the value 1001/ 5461, even though a numeric variable was concatenated with the value of a character variable. SAS performs automatic numericto-character conversion for the purpose of concatenation. When Item_Reference is created, the automatic conversion from numeric to character uses the BEST12. format for conversion, and the leading blanks are included in the converted value. 32. The following SAS program is submitted: data work.month; date=put('13mar2000'd,ddmmyy10.); run;

What are the type and length of the variable Date in the output data set? a. The type is numeric and the length is 8 bytes. b. The type is numeric and the length is 10 bytes. c. The type is character and the length is 8 bytes. d. The type is character and the length is 10 bytes. Correct answer: d Your answer: The PUT function converts numeric variables to character variables. You can use a format as the second argument to specify how to write the value. The length of a character variable is determined by the width that is specified in the format name. 33. A SAS program is submitted and the following is written to the SAS log:

SAS Log 178 179

data days; do i='SUN' 'MON' 'TUES'; ----- -----388 200 ERROR 388-185: Expecting an arithmetic operator. ERROR 300-322: The symbol is not recognized and will be ignored. 180 181 182

day=i!!'DAY'; end; run;

What caused the error? a. The list of values should be in parentheses. b. The values should be separated by commas. c. The values should not be in quotation marks. d. Character values are not allowed on a DO loop statement. Correct answer: b Your answer: Character values are allowed in a DO loop statement. If character values are used in the DO loop statement, the values should be separated by commas and enclosed in quotation marks. 34. The following SAS program is submitted: data work.clients; calls=6; do while(calls le 6); calls+1; end; calls+1; run;

What is the result? a. The variable Calls has a value of 6 in the output data set. b. The variable Calls has a value of 7 in the output data set. c. The variable Calls has a value of 8 in the output data set. d. The variable Calls has no value. The program fails to execute. Correct answer: c

Your answer: The DO WHILE loop checks the validity of the expression at the top of the loop and executes as long as the expression is true. When the expression is false, the DO loop does not execute. In this program, the value of Calls is set to 6 in the assignment statement at the beginning of the DATA step. Therefore, the expression in the DO/WHILE loop is true and the loop executes once. The loop increases the value of Calls to 7, so the loop expression fails and the DATA step continues with the sum statement. At the end of the DATA step, the value of Calls is 8. 35. The following SAS program is submitted: data stats; set revenue; array weekly{5} mon tue wed thu fri; total=weekly{i}*.25; output; end; run;

Which one of the following DO statements completes the program and processes the elements of the weekly array? a. do i=1-5; b. do i=1 to 5; c. do weekly=1 to 5; d. do weekly{i}=1 to 5; Correct answer: b Your answer: A simple DO loop can be used to process the elements in the array. When you define a DO loop that processes elements in an array, the index variable name should also be the name that is used for the subscript of the array reference. 36. The following program is submitted: data work.test; array diff_sales{3}; run;

Which of the variables are written to the Work.Test data set?

a. Diff_sales only b. Diff_sales3 only c. Diff_sales, Diff_sales1, Diff_sales2 d. Diff_sales1, Diff_sales2, Diff_sales3 Correct answer: d Your answer: The ARRAY statement creates an array named diff_sales. The diff_sales array has three elements. Because there are no variables referenced in a variable list in this array definition, this ARRAY statement creates three numeric variables named Diff_sales1, Diff_sales2, and Diff_sales3. 37. The following SAS program is submitted: proc report data=work.houses nowd; column style price; where price<100000; title; run;

The following list report is generated: Style of homes

Asking price $80,050

CONDO $79,350 $55,850 TWOSTORY $69,250

Which of the following DEFINE statements completes the program and produces the desired output? a. define price/sum format=comma9. width=10; b. define style/display width=9.; c. d.

define define define define define

price/sum format=comma9. width=10; style/group width=9; price/sum format=comma9. width=10; style/order width=9; price/sum format=comma9. width=10;

Correct answer: Your answer:

d

The detail report shown uses the variables Style and Price. The Style

variable is specified as an order variable by the ORDER usage option in the DEFINE statement. The DISPLAY usage option would print a detail report listing all of the values of Style. The GROUP usage option would suppress the repetitious printing of Style, but it would collapse all rows with the same Style value into one row. 38. The following SAS program is submitted: proc sort data=houses; by style; run; proc print data=houses; run;

The following list report is generated: style CONDO

bedrooms baths price 2 1.5 $80,050

TWOSTORY

3

2.5

$79,350

4

2.5 $127,150

2 4

2.0 $110,700 3.0 $107,250

2

1.0

2

1.0 $569,250

4

2.5 $102,950

$55,850

Which of the following SAS statements completes the program and creates the desired report? a. id style; b. c. d.

var bedroom baths price; id style; var style bedrooms baths price; id style; by style; var bedrooms baths price; id style; by style; var style bedrooms baths price;

Correct answer: Your answer:

c

The ID statement prints the ID variable as the left-most column and suppresses the OBS column. If you specify a variable in the ID statement and that same variable is listed in the VAR statement, then the variable appears twice in the report. The report lists the ID variable once for each BY group when you use the ID statement and the BY statement together, with the same variable listed in both statements. The BY lines are also suppressed in the report, and the value of the ID variable identifies the BY group. 39. The following SAS program is submitted: proc freq data=class; run;

The SAS data set Class has two character variables and three numeric variables. How many tables are generated? a. 0 b. 2 c. 3 d. 5 Correct answer: Your answer:

d

There are five tables generated. By default, the FREQ procedure generates a report that contains a frequency table for every variable in the data set, including both character and numeric variables. 40. The following SAS program is submitted: proc means data=sasuser.houses mean; run;

The following report is produced:

style

N Obs Variable Label

Mean

CONDO

4 bedrooms Number of bedrooms baths Number of bathrooms

2.7500000 2.1250000

RANCH

4 bedrooms Number of bedrooms baths Number of bathrooms

2.2500000 2.0000000

SPLIT

3 bedrooms Number of bedrooms baths Number of bathrooms

2.6666667 1.8333333

TWOSTORY

4 bedrooms Number of bedrooms baths Number of bathrooms

3.0000000 1.8750000

Which of the following statements completes the program and creates the desired report? a. class style; b. var bedrooms baths; c. class style; d.

var bedrooms baths; var style; class bedrooms baths;

Correct answer: Your answer:

c

In the desired report, the variable Style is a grouping variable, and the variables Bedrooms and Baths are analyzed. In the MEANS procedure, the CLASS statement specifies grouping variables. The VAR statement specifies which numeric variables are analyzed. 41. The following SAS program is submitted: options pageno=1 number; proc print data=sasuser.houses; run; proc means data=sasuser.shoes; run;

The report created by the PRINT procedure generates five pages of output. What is the page number on the first page that is generated by the MEANS procedure? a. 1 b. 2 c. 5 d. 6 Correct answer: Your answer:

d

The PAGENO= option specifies a starting page number for the output. The page numbers increment by 1, starting with the value in the PAGENO= option. If the PRINT procedure generates five pages of output, then the MEANS procedure output will start on page 6. If you move the OPTIONS statement after the PRINT procedure, the MEANS procedure output would start on page 1. 42. Which one of the following statements describes creating user-defined formats with the FORMAT procedure? a. b. c. d.

User-defined formats cannot end in a number. The format name can be up to 200 characters in length. The format name can end with a period in the value statement. User-defined formats can share a name with a SAS format if they are stored in a different location. Correct answer: a Your answer: User-defined formats are created using the FORMAT procedure. The name of the user-defined format is specified in the VALUE statement. The name of the user-defined format must start with a letter or an underscore, and can continue with any letter, number, or underscore up to 32 characters. However, the name of the user-defined format cannot end in a number. The name of a user-defined format cannot be the name of an existing SAS format. When you specify the name of a user-defined format in the VALUE statement, you do not use a period. 43. 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. 1 b. 2 c. 3 d. 4 Correct answer: Your answer:

a

This program creates one HTML file named Newfile.html. By default, one HTML file is created for each FILE= 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. 44. Which statement directs output to an HTML file? a. the ODS HTML statement b. the HTML statement c. the EXPORT statement d. the PRINTTO statement Correct answer: a Your answer: The ODS HTML statement directs output to an HTML file. HTML is an option that can be used in the ODS HTML statement to specify which destination you are opening and/or closing. EXPORT and PRINTTO are procedures in SAS, not statements. 45. The following SAS program is submitted: data test; set ia.flts_pts; if job_code='fltat3' then description='Flight Attendant'; length description 8; run; The variable Job_code is a character variable with a length

of 6 bytes.

What is the result? a. b. c. d.

The variable Description with a length of 6 bytes is created. The variable Description with a length of 8 bytes is created. The variables Description with a length of 16 bytes is created. The variable Description is not created. The DATA step fails because of errors.

Correct answer: Your answer:

d

The DATA step fails because of errors. The LENGTH statement can be used to assign a length to a character or numeric variable. When this code is compiled, SAS encounters description in the assignment statement before the LENGTH statement, and description is set to a character variable with a length of 16. When the LENGTH statement compiles, there is a conflict because the LENGTH statement attempts to assign a numeric length to the character variable Description, and the step fails because of the error. 46. The descriptor and data portions of the Work.Salaries data set are shown below. Variable Type Len Pos name

Char 8

0

salary

Char 8

16

status

Char 8

8

name status salary Liz

S

15,600

Herman S

26,700

Marty

35,000

S

The following SAS program is submitted: proc print data=work.salaries; where salary<20000; run;

No observations are output. Which of the following answers would result in a report of individuals with Salary less than $20,000 upon reexecution of the program? a. Right justify the Salary value in the WHERE statement in the PRINT step. b. Use a PUT function to write the Salary values with leading zeroes in a DATA step before the PRINT step. c. Change 20000 (which is a numeric constant) to '20,000' (which is a character constant) in the WHERE statement in the PRINT step. d. Convert the Salary values to numeric values in a DATA step before the PRINT step.

Correct answer: Your answer:

c

In order to output the desired observations, you must specify the value in the WHERE statement as a character value. Salary is defined as a character variable. The variable and value that are referenced in the WHERE statement must be of the same type. 47. The following SAS program is submitted: data work.totalsales; set work.monthlysales(keep=year product sales); retain monthsales{12}; array monthsales{12}; do i=1 to 12; monthsales{i}=sales; end; cnt+1; monthsales{cnt}=sales; run;

The data set named Work.Monthlysales has one observation per month for each of five years for a total of 60 observations. What is the result? a. The program fails execution because of data errors. b. The program fails execution because of syntax errors. c. The program runs with warnings and creates the Work.Totalsales data set with 60 observations. d. The program runs without errors or warnings and creates the Work.Totalsales data set with 60 observations. Correct answer: b Your answer: The program fails to execute because there is a syntax error in the RETAIN statement. The curly brackets are used to define the array elements in the ARRAY statement. Curly brackets are not used to define the initial value for a variable in the RETAIN statement. 48. Which one of the following TITLE statements displays Jane's Dog as the title of SAS output? a. title "Jane"s Dog"; b. title 'Jane"s Dog'; c. title "Jane's Dog"; d. title 'Jane' ' 's Dog'l Correct answer: c

Your answer: To hide an unmatched single quotation mark, you surround the title text with matched double quotation marks. SAS expects single and double quotation marks to be in pairs. 49. The data set Work.Allmonths contains four quarters of data. A DATA step is submitted and a portion of the SAS log is shown below. SAS Log 208 209 210 211 212 213 214 215 216

data arrays; set work.allmonths(keep=quarter num_sold); by quarter; array sold{3}; if first.quarter then cnt=1; sold{cnt}=num_sold; cnt+1; if last.quarter then output; run;

ERROR: Array subscript out of range at line 213 column 4. quarter=2 num_sold=3 FIRST.quarter=0 LAST.quarter=1 sold1=. sold2=. sold3=. cnt=4 _ERROR_=1 _N_=7 NOTE: The SAS System stopped processing this step because of errors. NOTE: There were 8 observations read from the dataset WORK.ALLMONTHS. WARNING: The data set WORK.ARRAYS may be incomplete. When this step was stopped there were 1 observations and 6 variables. WARNING: Data set WORK.ARRAYS was not replaced because this step was stopped. NOTE: DATA statement used: real time 0.10 seconds

Which of the following answers would correct the error message? a. Reverse the order of lines 213 and 214. b. Increase the ARRAY dimension to a value of 4. c. Sort the Work.Allmonths data set in descending order by the Quarter variable. d. Add a WHERE= data set option to the Work.Allmonths data set to limit values of the variable Cnt to 3 or less. Correct answer: b Your answer: There are three dimensions in the sold array and four quarters of data. When the Cnt variable has a value of 4, the value exceeds the specified

range in the array and causes SAS to stop processing. Because there are four quarters, increasing the array dimension value to 4 will accommodate all of the elements within the array. 50. The following SAS program is submitted: data test; infile 'file-specification'; input country $ amount; run;

Which one of the following automatic variables can be used to test whether a value for the variable Amount is non-numeric? a. _N_ b. _ERROR_ c. _NUMERIC_ d. _CHARACTER_ Correct answer: b Your answer: is an automatic variable that is created by the DATA step. records when an error is encountered. The value of _ERROR_ is set to 0 by default, and the value changes to 1 when an input error occurs. _N_ is an automatic variable that is created by the DATA step. The value of _N_ represents the number of times the DATA step has iterated. _NUMERIC_ and _CHARACTER_ are not automatic DATA step variables; they are reserved names for use as variable name lists. _ERROR_ _ERROR_

Copyright © 2006 SAS Institute Inc., Cary, NC, USA. All rights reserved. Terms of Use & Legal Information | Privacy Statement

Related Documents

Paper3
November 2019 16
Chemistry Paper3
October 2019 24
Wipro Paper3
April 2020 1
Paper3 Traduzido
June 2020 8
Sample Paper3
June 2020 12
Paper3 Eastern
May 2020 7