Chapter 13 - Transforming Data with SAS functions

Description

Quiz on Chapter 13 - Transforming Data with SAS functions, created by James Blair on 23/10/2014.
James Blair
Quiz by James Blair, updated more than 1 year ago
James Blair
Created by James Blair over 9 years ago
220
0

Resource summary

Question 1

Question
Which function calculates the average of the variables Var1, Var2, Var3, and Var4?
Answer
  • a. mean( var1, var4)
  • b. mean( var1-var4)
  • c. mean( of var1, var4)
  • d. mean( of var1-var4)

Question 2

Question
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;
Answer
  • a. SAS converts the values of PayRate to numeric values. No message is written to the log.
  • b. SAS converts the values of PayRate to numeric values. A message is written to the log.
  • c. SAS converts the values of Hours to character values. No message is written to the log.
  • d. SAS converts the values of Hours to character values. A message is written to the log.

Question 3

Question
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?
Answer
  • a. TargetNo = input( target, comma6.);
  • b. TargetNo = input( target, comma7.);
  • c. TargetNo = put( target, comma6.);
  • d. TargetNo = put( target, comma7.)

Question 4

Question
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?
Answer
  • a. Location = dept | |'/' | | input( sitenum, 3.1);
  • b. Location = dept | |'/' | | input( sitenum, 4.1);
  • c. Location = dept | |'/' | | put( sitenum, 3.1);
  • d. Location = dept | |'/' | | put( sitenum, 4.1);

Question 5

Question
Suppose the YEARCUTOFF = system option is set to 1920. Which MDY function creates the date value for January 3, 2020?
Answer
  • a. MDY( 1,3,20)
  • b. MDY( 3,1,20)
  • c. MDY( 1,3,2020)
  • d. MDY( 3,1,2020)

Question 6

Question
The variable Address2 contains values such as Piscataway, NJ. How do you assign the two-letter state abbreviations to a new variable named State?
Answer
  • a. State = scan( address2,2);
  • b. State = scan( address2,13,2);
  • c. State = substr( address2,2);
  • d. State = substr( address2,13,2);

Question 7

Question
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?
Answer
  • a. Sex = scan( idcode, 4);
  • b. Sex = scan( idcode, 4,1);
  • c. Sex = substr( idcode, 4);
  • d. Sex = substr( idcode, 4,1);

Question 8

Question
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?
Answer
  • 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, 5,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;

Question 9

Question
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?
Answer
  • a. data work.maillist; set retail.maillist; length FullName $ 40; fullname = trim firstname | |' '| | lastname; run;
  • b. data work.maillist; set retail.maillist; length FullName $ 40; fullname = trim( firstname) | |' '| | lastname; run;
  • c. data work.maillist; set retail.maillist; length FullName $ 40; fullname = trim( firstname) | |' '| | trim( lastname); run;
  • d. data work.maillist; set retail.maillist; length FullName $ 40; fullname = trim( firstname | |' '| | lastname); run;

Question 10

Question
Within the data set Furnitur.Bookcase, the variable Finish contains values such as ash/ cherry/ teak/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.
Answer
  • a. data work.bookcase; set furnitur.bookcase; if index( finish, walnut) = 0; run;
  • b. data work.bookcase; set furnitur.bookcase; if index( finish,' walnut') > 0; run;
  • c. data work.bookcase; set furnitur.bookcase; if index( lowcase( finish), walnut) = 0; run;
  • d. data work.bookcase; set furnitur.bookcase; if index( lowcase( finish),' walnut') > 0; run;
Show full summary Hide full summary

Similar

Statistics Key Words
Culan O'Meara
SAMPLING
Elliot O'Leary
FREQUENCY TABLES: MODE, MEDIAN AND MEAN
Elliot O'Leary
CUMULATIVE FREQUENCY DIAGRAMS
Elliot O'Leary
TYPES OF DATA
Elliot O'Leary
HISTOGRAMS
Elliot O'Leary
GROUPED DATA FREQUENCY TABLES: MODAL CLASS AND ESTIMATE OF MEAN
Elliot O'Leary
Statistics Vocab
Nabeeha Yusuf
HTTPS explained with Carrier Pigeons
Shannon Anderson-Rush
chapter 1,2 statistics
Rigo Sanchez
Statistics, Data and Area (Semester 2 Exam)
meg willmington