Chapter 14: Using Functions to Manipulate Data

  1. Correct answer: b
    When this DATA step is executed, SAS automatically converts the character values of PayRate to numeric values so that the calculation can occur. Whenever data is automatically converted, a message is written to the SAS log stating that the conversion has occurred.
  2. Correct answer: b
    You explicitly convert character values to numeric values by using the INPUT function. Be sure to select an informat that can read the form of the values.
  3. Correct answer: d
    You explicitly convert numeric values to character values by using the PUT function. Be sure to select a format that can read the form of the values.
  4. Correct answer: a
    The SCAN function is used to extract words from a character value 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.
  5. Correct answer: d
    The SUBSTR function is best used when you know the exact position of the substring to extract from the character value. You specify the position to start from and the number of characters to extract.
  6. Correct answer: c
    The SUBSTR function replaces variable values if it is placed on the left side of an assignment statement. When placed on the right side (as in Question 5), the function extracts a substring.
  7. Correct answer: b
    The TRIM function removes trailing blanks from character values. In this case, extra blanks must be removed from the values of FirstName. Although answer c also works, the extra TRIM function for the variable LastName is unnecessary. Because of the LENGTH statement, all values of FullName are padded to 40 characters.
  8. Correct answer: d
    Use the INDEX function in a subsetting IF statement, enclosing the character string in quotation marks. Only those observations in which the function locates the string and returns a value greater than 0 are written to the data set.
Last updated: August 23, 2018
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.197.251