Module 8 Chapter Review

¡Supera tus tareas y exámenes ahora con Quizwiz!

b

Given the same value as an argument, do the INT and the FLOOR functions always return the same result? a.Yes b.No

b Adding the amount from all three orders and then subtracting the amount of the smallest order leaves the sum of the two largest orders.

Ord1, Ord2, and Ord3 are variables that contain the sale amounts of the last three orders from all customers who have three orders or more. Which of the following expressions can calculate the total of the two largest orders? a. sum(max(of Ord1-Ord3),max(of Ord1-Ord3)) b. sum(of Ord1-Ord3)-min(of Ord1-Ord3) c. max(of Ord1-Ord3) + min(of Ord1-Ord3) d. none of the above

d

What expression completes the assignment statement to correctly extract 2007 from the Text variable? a. scan(Text,-1); b. scan(Text,6); c. scan(Text,6,', '); d. All of the above would work.

c

Which SUBSTR function can extract the group of five numbers from the middle of the Item_Code value? a. substr(Item_Code,5,7) b. substr(Item_Code,5) c. substr(Item_Code,7,5) d. substr(Item_Code,'mid',5)

When you submit the following program, what is listed in the log? data work.holdings; set work.catalog end=last; if _n_=1 then putlog 'books'; if last then do; putlog 'last of books'; putlog _all_; end; run; a.books, last of books, and the values for all the variables in the last observation b.books, last of books, and the values for all the variables in all observations c.the values of all the variables for the last observation

a

1.When a logic error occurs, SAS displays unexpected results. a.true b.False

a

2.Logic errors are often more difficult to detect than syntax errors. a.true b.False

a

The END= option in the SET or INFILE statement creates a variable that acts as an end-of-file indicator. a.true b.False

a

1.The variable Address2 contains values such as Piscataway, NJ. Select the statement that extracts and assigns the two-letter state abbreviation to a new variable named State. a.State=scan(Address2,2); b.State=scan(Address2,13,2); c.State=substr(Address2,2); d.State=substr(Address2,13,2);

a.State=scan(Address2,2); The SCAN function is used to extract words from a character when you know the order of the words, when their position varies, and when the words are marked by some delimiter. In this case, you do not need to specify delimiters, because the blank and the comma are default delimiters.

8.Which of the following functions can convert the values of the numeric variable Level to character values? a.put(Level,3.) b.input(3.,Level) c.put(3.,Level) d.input(Level,3.)

a.put(Level,3.) The PUT function explicitly converts numeric values to character values. You specify the keyword PUT followed by the variable name and then the format. The variable name and format are enclosed in parentheses and separated by a comma.

3.When a logic error occurs, SAS writes an error message to the log. a.true b.False

b

4.Logic errors occur when program statements do not conform to the rules of the SAS language. a.true b.False

b

4.Within the data set furn.bookcase, the variable Finish contains values such as ash, cherry, teak, and matte-black. Which of the following creates a subset of the data in which the values of Finish contain the string walnut? Make the search for the string case-insensitive. a. data work.bookcase; set furn.bookcase; if find(finish,'walnut',I); run; b. data work.bookcase; set furn.bookcase; if find(finish,'walnut','I')>0; run;

b. data work.bookcase; set furn.bookcase; if find(finish,'walnut','I')>0; run; When you use the I modifier in the FIND function to make the search case-insensitive, you must enclose it in quotation marks.

3.Due to growth within the 919 area code, the telephone exchange 555 is being reassigned to the 920 area code. The data set clients.piedmont includes the variable Phone, which contains the telephone number in the form 808-555-1234. Which of the following programs correctly changes the values of Phone? a. data work.piedmont(drop=areacode exchange); set clients.piedmont; Areacode=substr(phone,1,3); Exchange=substr(phone,5,3); if areacode='919' and exchange='555' then phone=substr('920',1,3); run; b. data work.piedmont(drop=areacode exchange); set clients.piedmont; Areacode=substr(phone,1,3); Exchange=substr(phone,5,3); if areacode='919' and exchange='555' then substr(phone,1,3)='920'; run;

b. data work.piedmont(drop=areacode exchange); set clients.piedmont; Areacode=substr(phone,1,3); Exchange=substr(phone,5,3); if areacode='919' and exchange='555' then substr(phone,1,3)='920'; run; When the SUBSTR function is used on the left side on an assignment statement, it replaces characters at a specified position.

7.The END= option in the SET or INFILE statement indicates that SAS should process the last observation. a.true b.False

b.False The END= option creates a variable that can be used to detect the last observation being read. It does not control whether the last observation is executed.

5.Which of the following is not a task of the PUTLOG statement? a.Write text to the log. b.Write formatted values to the log. c.Write all the logic errors to the log. d.Write the values of all the variables to the log.

c

6.The variable Title is 22 characters long. One of the values for Title is My House on the Lane. Which of the following statements would provide the full value of the variable in the log if the data included two leading spaces? a.putlog Title $quote20.; b.putlog Title $quote22.; c.putlog Title $quote30.;

c The value of the width must be wide enough to display the value of the variable as well as the quotation marks.

7.Which function returns the greatest integer less than or equal to the argument? a.CEIL b.INT c.FLOOR

c.FLOOR The FLOOR function returns the greatest integer less than or equal to the argument.

5.What is the new value of Code? Code="HNL:96701-006"; Code=substr(Code,1,length(Code)-4); a.96701-006 b.HNL: c.HNL:96701 d.1-006

c.HNL:96701 When functions are nested, the innermost function executes first and passes its result to an outer function. The LENGTH function returns the length of the string (13) to the SUBSTR function. The SUBSTR function extracts a nine-character string (13-4) starting from position 1.

10.Which of the following functions converts the character values of Base to numeric values? a.put(comma10.2,Base) b.put(Base,comma10.2) c.input(Base,comma10.2) d.input(comma10.2, Base)

c.input(Base,comma10.2) The INPUT function explicitly converts character values to numeric values. You specify the keyword INPUT followed by the variable name and then the INFORMAT. The variable name and INFORMAT are enclosed in parentheses and separated by a comma. A numeric INFORMAT is needed for character-to-numeric conversions.

2.The variable IDCode contains values such as 123FA and 321MB. The fourth character identifies gender. Select the statement that assigns this character code to a new variable named Gender. a.Gender=scan(IDCode,4); b.Gender=scan(IDCode,4,1); c.Gender=substr(IDCode,4); d.Gender=substr(IDCode,4,1);

d.Gender=substr(IDCode,4,1); The SUBSTR function is best used when you know the exact position of the substring to extract from the character value. You specify the variable, the starting position, and the number of characters to extract.

9.A typical value for the numeric variable SiteNum is 12.3. Which statement correctly converts the values of SiteNum to character values when creating the variable Location? a.Location=Dept||'/'||put(SiteNum, $3); b.Location=Dept||'/'||put(SiteNum,4); c.Location=Dept||'/'||put(SiteNum,3.1); d.Location=Dept||'/'||put(SiteNum,4.1);

d.Location=Dept||'/'||put(SiteNum,4.1); When you use the PUT function, you must specify a format that can write the form of the values. The numeric format 4.1 correctly writes the values of SiteNum.

6.Which function calculates the average of the variables Var1, Var2, Var3, and Var4? a.mean(Var1,Var4) b.mean(Var1-Var4) c.mean(of Var1,Var4) d.mean(of Var1-Var4)

d.mean(of Var1-Var4) You can use a numbered range list to specify the variables Var1 through Var4. When you use a variable list, you must precede the list with the keyword OF. If you omit the OF, SAS does not interpret the arguments correctly.


Conjuntos de estudio relacionados

Chapter 26 Digestive System Objectives

View Set

Chapter 3 section 1 vocabulary and questions

View Set

intro mass communication exam 3 over chapters 11-12 and 14-15

View Set

Hygiene and Prevention Chapter Exam

View Set

Legal Descriptions (Real Estate)

View Set

Compensation: Exam 1 (STUDY GUIDE)

View Set

AP Stats TPS4e Ch 10.1 Comparing Two Proportions

View Set