SAS Chapter 14

10 Questions | Attempts: 224
Please wait...
Question 1 / 11
🏆 Rank #--
Score 0/100

1. A typical value for the character variable Target is 123,456.  Which statement correctly converts the values of Target to numeric values when creating the variable TargetNo?

Explanation

You explicitly convert character values to numeric values by using INPUT function. Be sure to select an informat that can read the form of the values.

Submit
Please wait...
About This Quiz
SAS Quizzes & Trivia

Practice for the SAS base certification exam.

2.

What first name or nickname would you like us to use?

You may optionally provide this to label your report, leaderboard, or certificate.

2. Within the data set Hrd.Temp, PayRate is a character variable and Hours is a numeric variable.  What happens when the following program is run? data work.temp;    set hrd.temp;    Salary=payrate*hours; run;

Explanation

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.

Submit

3. Which function calculates the average of the variables Var 1, Var 2, Var 3, and Var 4?

Explanation

Use a variable list to specify a range of variables as the function argument. When specifying a variable list, be sure to precede the list with the word OF. If you omit the word OF, the function argument might not be interpreted as expected.

Submit

4. Suppose the YEARCUTOFF= system option is set to 1920.  Which MDY function creates the date value for January 3, 2020?

Explanation

Because the YEARCUTOFF= system option is set to 1920, SAS sees the two-digit year value 20 as 1920. Four-digit year values are always read correctly.

Submit

5. The variable IDCode contains values such as 123FA and 321MB.  The fourth character identifies sex.  How do you assign these character codes to a new variable named Sex?

Explanation

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 the number of characters to extract.

Submit

6. 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?

Explanation

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.

Submit

7. Due to the 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 telephone numbers in the form 919-555-1234.  Which of the following programs will correctly change the values of Phone?

Explanation

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 7), the function extracts a substring.

Submit

8. The variable Address2 contains values such as Piscataway, NJ.  How do you assign the two-letter state abbreviations to a new variable named State?

Explanation

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 don't need to specify delimiters, because the blank and the comma are default delimiters.

Submit

9. Within the data set Furnitur.Bookcase, the variable Finish contains values such as ash/cherry/teak/matte-black.  Which of the follwoing creates a subset of the data in which the values of Finish contain the string walnut?  Make the search for the string case-insensitive.

Explanation

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.

Submit

10. Suppose you need to create the variable FullName by concatenating the values of FirstName, which contains first names, and LastName, which contains last names.  What's the best way to remove extra blanks between first names and last names?

Explanation

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.

Submit
×
Saved
Thank you for your feedback!
View My Results
Cancel
  • All
    All (10)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
A typical value for the character variable Target is 123,456....
Within the data set Hrd.Temp, PayRate is a character variable and...
Which function calculates the average of the variables Var 1, Var 2,...
Suppose the YEARCUTOFF= system option is set to 1920.  Which MDY...
The variable IDCode contains values such as 123FA and 321MB.  The...
A typical value for the numeric variable SiteNum is 12.3.  Which...
Due to the growth within the 919 area code, the telephone exchange 555...
The variable Address2 contains values such as Piscataway, NJ....
Within the data set Furnitur.Bookcase, the variable Finish contains...
Suppose you need to create the variable FullName by concatenating the...
play-Mute sad happy unanswered_answer up-hover down-hover success oval cancel Check box square blue
Alert!