Chapter Quiz

Select the best answer for each question. Check your answers using the answer key in the appendix.
  1. Within the data set Cert.Temp, PayRate is a character variable and Hours is a numeric variable. What happens when the following program is run?
    data work.temp; 
       set cert.temp; 
       Salary=payrate*hours; 
    run;
    1. SAS converts the values of PayRate to numeric values. No message is written to the log.
    2. SAS converts the values of PayRate to numeric values. A message is written to the log.
    3. SAS converts the values of Hours to character values. No message is written to the log.
    4. SAS converts the values of Hours to character values. A message is written to the log.
  2. 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?
    1. TargetNo=input(target,comma6.);
    2. TargetNo=input(target,comma7.);
    3. TargetNo=put(target,comma6.);
    4. TargetNo=put(target,comma7.)
  3. 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?
    1. Location=dept||'/'||input(sitenum,3.1);
    2. Location=dept||'/'||input(sitenum,4.1);
    3. Location=dept||'/'||put(sitenum,3.1);
    4. Location=dept||'/'||put(sitenum,4.1);
  4. The variable Address2 contains values such as Piscataway, NJ. How do you assign the two-letter state abbreviations to a new variable named State?
    1. State=scan(address2,2);
    2. State=scan(address2,13,2);
    3. State=substr(address2,2);
    4. State=substr(address2,13,2);
  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?
    1. Sex=scan(idcode,4);
    2. Sex=scan(idcode,4,1);
    3. Sex=substr(idcode,4);
    4. Sex=substr(idcode,4,1);
  6. Because of 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 correctly changes the values of Phone?
    1. data work.piedmont(drop=areacode exchange); 
        set cert.piedmont; 
        Areacode=substr(phone,1,3); 
        Exchange=substr(phone,5,3); 
        if areacode='919' and exchange='555' 
          then scan(phone,1,3)='920'; 
      run;
    2. data work.piedmont(drop=areacode exchange); 
        set cert.piedmont; 
        Areacode=substr(phone,1,3); 
        Exchange=substr(phone,5,3); 
        if areacode='919' and exchange='555' 
          then phone=scan('920',1,3); 
      run;
    3. data work.piedmont(drop=areacode exchange); 
        set cert.piedmont; 
        Areacode=substr(phone,1,3); 
        Exchange=substr(phone,5,3); 
        if areacode='919' and exchange='555' 
          then substr(phone,1,3)='920'; 
      run;
    4. data work.piedmont(drop=areacode exchange); 
        set cert.piedmont; 
        Areacode=substr(phone,1,3); 
        Exchange=substr(phone,5,3); 
        if areacode='919' and exchange='555' 
          then phone=substr('920',1,3); 
      run;
  7. 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 is the best way to remove extra blanks between first names and last names?
    1. data work.maillist; 
        set cert.maillist; 
        length FullName $ 40; 
        fullname=trim firstname||' '||lastname; 
      run;
    2. data work.maillist; 
        set cert.maillist; 
        length FullName $ 40; 
        fullname=trim(firstname)||' '||lastname; 
      run;
    3. data work.maillist; 
        set cert.maillist; 
        length FullName $ 40; 
        fullname=trim(firstname)||' '||trim(lastname); 
      run;
    4. data work.maillist; 
        set cert.maillist; 
        length FullName $ 40; 
        fullname=trim(firstname||' '||lastname); 
      run;
  8. Within the data set Cert.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.
    1. data work.bookcase; 
        set cert.bookcase; 
        if index(finish,walnut) = 0; 
      run;
    2. data work.bookcase; 
        set cert.bookcase; 
        if index(finish,'walnut') > 0; 
      run;
    3. data work.bookcase; 
        set cert.bookcase; 
        if index(lowcase(finish),walnut) = 0; 
      run;
    4. data work.bookcase; 
        set cert.bookcase; 
        if index(lowcase(finish),'walnut') > 0; 
      run;
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
18.222.22.145