| Quiz:
Transforming
Data with SAS Functions
Select the best answer for each question and click Score My Quiz.
-
Which function calculates the
average of the variables
Var1, Var2, Var3,
and Var4?
-
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;
-
A typical value for the character
variable
Target is 123,456. Which statement
correctly converts these to numeric values when creating the variable
TargetNum?
-
A typical value for the numeric
variable
SiteNum is 12.3. Which statement correctly
converts these to character values when creating the variable Location?
-
Suppose the YEARCUTOFF= system
option is set to 1920. Which MDY function creates the date value for
January 3, 2020?
-
The variable
Address2
contains values such as Piscataway, NJ. How do you assign
the two-letter state abbreviations to a new variable named State?
-
The variable
IdentCode
contains values such as 321F. The fourth character identifies
sex. How do you assign these character codes to a new variable named
Sex?
-
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 telephone numbers in the
form 919-555-1234. Which of the following programs will correctly
change 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 scan(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 phone=scan('920',1,3);
run;
|
|
|
c. |
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;
|
|
|
d. |
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;
|
-
Suppose you need to create the
variable
FullName by concatenating the values of Fname,
containing first names, and Lname, containing last names.
What's the best way to remove extra blanks between first names and
last names?
-
Within the data set Furniture.Bookcases,
the variable
Finish contains values such as ash/cherry/teak/matte-black.
Which of the following creates a subset of the data where the values
of Finish contain the string walnut? Make the
search for the string case-insensitive.
|