Chapter Review Quiz


Manipulating Data

Select the best answer for each question. When you are finished, click Submit Quiz.

  1. Based on this program and the observation shown in the PDV, what variable's value will be assigned to Amount?

    data payroll;
       set salaries;
       if PayClass='Monthly' then Amount=Salary;
       else if PayClass='Hourly' then do;
          Amount=HrlyWage*Hrs;
          if Hrs>40 then Msg='CHECK TIMECARD'; 
       end;     
       else Amount=JobRate;
    run;
    

    PDV

    EmpID
    PayClass
    Hrs
    Amount
    JobRate
    Msg
    1201
    Contract
    30
    .
    .
     

     a.   not specified
     b.   HrlyWage*Hrs
     c.   JobRate
     d.   Salary


  2. Which of the following SAS functions returns a number from 1 to 12?

     a.   YEAR(SAS-date)
     b.   MONTH(SAS-date)
     c.   WEEKDAY(SAS-date)
     d.   TODAY(SAS-date)


  3. The data set orion.sales contains nine variables. Given this DATA step, how many variables does the descriptor portion of work.comp contain?

    date work.comp;
       set orion.sales;
       drop Gender Salary Country;
       Compensation=sum(Salary,Bonus);
    run;
     a.   6
     b.   7
     c.   10
     d.   None. This program contains a logic error.


  4. Which DATA step ensures that all observations are assigned a nonmissing value for Bonus?


     a.  
    data work.bonus;
       set orion.sales;
       if Country='US' then Bonus=500;
       else if Country='AU' then Bonus=300;
    run:
     b.  
    data work.bonus;
       set orion.sales;
       if Country='US' then Bonus=500;
       else Bonus=300;
    run:


  5. In the DATA step below, what is the length of the new variable, Type?

    data orion.newloan; 
       set orion.records; 
       TotalPaid=sum(TotLoan+Interest); 
       if Code='1' then Type='Fixed'; 
       else Type='Variable'; 
       length Type $ 10; 
    run;
     a.   5
     b.   8
     c.   10
     d.   It depends on the first value of Type in orion.records.


  6. In the program below, what is the value of Benefit for the observation shown?

    data work.total;
       set payroll.june;
       Benefit=sum(Ins,Health_Award);
    run;

    PDV

    EmpID
    Salary
    Ins
    Bonus
    Health_Award
    Benefit
    KBA
    54000
    800
    250
    .
    .

     a.   a missing value
     b.   55050
     c.   800
     d.   0


  7. Which of these statements does not correctly specify a SAS function?

     a.  
    Deadline=sum(TimeSpent, Last_Name);
     b.  
    GreatDay=today();
     c.  
    FingersToes=sum(10,10);
     d.  
    BirthdayYear=year('12dec1987'd);


  8. Given what you know about how SAS processes the DROP and KEEP statements, would these two DATA steps create the same data set?

    data work.subset1;
       set orion.sales;
       drop Salary;
       Bonus=500;
       Compensation=sum(Salary,Bonus);
       BonusMonth=month(Hire_Date);
    run;
    data work.subset1;
       set orion.sales;
       Bonus=500;
       Compensation=sum(Salary,Bonus);
       BonusMonth=month(Hire_Date);
       drop Salary;
    run;

     a.   Yes
     b.   No


  9. Which of the following determines the length of a new variable at compile time?

     a.   INPUT statement
     b.   assignment statement
     c.   LENGTH statement
     d.   all of the above


  10. Use a DO group in a DATA step when you want to execute multiple statements for a true IF-THEN expression.

     a.   True
     b.   False