SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Quiz: Reading and Concatenating SAS Data Sets

Select the best answer for each question and click Score My Quiz.

  1. Which of the following programs correctly reads the data set Orders and creates the data set FastOrders?

     a.  
    data catalog.FastOrders(drop=ordertime);
       set july.orders(keep=product units price);
       if ordertime<4;
       Total=units*price;
    run; 
     
     b.  
    data catalog.Orders(drop=ordertime);
       set july.FastOrders(keep=product units price);
       if ordertime<4;
       Total=units*price;
    run; 
     
     c.  
    data catalog.FastOrders(drop=ordertime);
       set july.orders(keep=product units price
                       ordertime);
       if ordertime<4;
       Total=units*price;
    run; 
     
     d.   none of the above

  2. Suppose you combine DataA and DataB. Which program below creates DataC?
    DataA
    ID Name Dept Project
    000 Miguel A12 Document
    111 Fred B45 Survey
    222 Diana B45 Document
    888 Monique A12 Document
    999 Vien D03 Survey
    DataB
    ID Name Hours
    111 Fred 35
    222 Diana 40
    777 Steve 0
    888 Monique 37
    DataC
    ID Name Dept Project Hours
    000 Miguel A12 Document .
    111 Fred B45 Survey 35
    222 Diana B45 Document 40
    777 Steve     0
    888 Monique A12 Document 37
    999 Vien D03 Survey .

     a.  
    data DataC;
       set dataa datab;
    run; 
     
     b.  
    data DataC;
       set datab dataa;
    run; 
     
     c.  
    data DataC;
       merge dataa datab;
       by id;
    run; 
     
     d.   none of the above

  3. If you submit the following program, which new data set is created?
    DataD
    Career Supervis Finance
    72 26 9
    63 76 7
    96 31 7
    96 98 6
    84 94 6
    DataE
    Variety Feedback Autonomy
    10 11 70
    85 22 93
    83 63 73
    82 75 97
    36 77 97
    data JobSatisfaction;
       set datad datae;
    run;        

     a.  
    Career Supervis Finance Variety Feedback Autonomy
    72 26 9 . . .
    63 76 7 . . .
    96 31 7 . . .
    96 98 6 . . .
    84 94 6 . . .
    . . . 10 11 70
    . . . 85 22 93
    . . . 83 63 73
    . . . 82 75 97
    . . . 36 77 97

     b.  
    Career Supervis Finance Variety Feedback Autonomy
    72 26 9 10 11 70
    63 76 7 85 22 93
    96 31 7 83 63 73
    96 98 6 82 75 97
    84 94 6 36 77 97

     c.  
    Career Supervis Finance
    72 26 9
    63 76 7
    96 31 7
    96 98 6
    84 94 6
    10 11 70
    85 22 93
    83 63 73
    82 75 97
    36 77 97

     d.   none of the above

  4. If you submit this program, which new data set is created?
    data gym(drop=age);
       set fitness(keep=activity dietchange sessions age);
       if age>30 and dietchange='yes';
    run;

     a.  
    Activity DietChange Sessions Age
    aerobics yes 13 53
    yoga yes 3 43
    weights yes 3 36
    team yes 12 49
    cross yes 11 52

     b.  
    Activity DietChange Sessions
    aerobics yes 13
    yoga yes 3
    weights yes 3
    team yes 12
    cross yes 11

     c.  
    Activity DietChange Age
    aerobics yes 53
    yoga yes 43
    weights yes 36
    team yes 49
    cross yes 52

     d.  
    Activity DietChange Sessions
    aerobics yes 13
    aerobics no 8
    yoga yes 3
    yoga no 2
    weights yes 3
    weights no 19
    team yes 12
    team no 16
    cross yes 11
    cross no 13

  5. Which of the following programs contains an error?

     a.  
    data newstudy(drop=count);
       set studybandaid;
       if count>20;
    run; 
     
     b.  
    data newstudy;
       set studybandaid(drop=clinic);
       if outcome='complain';
    run; 
     
     c.  
    data newstudy(drop=clinic);
       set studybandaid;
       if type=regular;
    run; 
     
     d.  
    data newstudy(drop=clinic);
       set studybandaid(drop=type);
       if count<35;
    run;

  6. If you concatenate the data sets DataF and DataG below, what happens?
    DataF
    Clinic Type Outcome Count
    A regular complain 14
    A test complain 11
    B regular complain 22
    B test complain 10
    C regular complain 22
    C test complain 15
    D regular complain 15
    D test complain 8
    E regular complain 20
    E test complain 15
    DataG
    Clinic Type Outcome Count
    A regular no 17
    A test no 31
    B regular no 21
    B test no 40
    C regular no 28
    C test no 30
    D regular no 18
    D test no 29
    E regular no 30
    E test no 29

     a.   The two data sets are combined side by side, for a total of 10 observations and 8 variables.
     b.   The two data sets are combined so that observation 1 in DataF is followed by observation 1 in DataG, observation 2 in DataF is followed by observation 2 in DataG, and so on.
     c.   The two data sets are combined one after another so that the first 10 observations in the new data set come from DataF and the second 10 observations come from DataG.
     d.   The two data sets are combined for a total of 10 observations and 8 variables, with missing values for the last 4 variables in the first 10 observations and missing values for the first 4 variables in the last 10 observations.

  7. Which of the following statements is true?

     a.   You can concatenate any number of data sets.
     b.   You can concatenate any number of data sets, but the data sets must contain all like-named variables.
     c.   You can merge any number of data sets, but you can concatenate only up to 32 data sets.
     d.   You can concatenate any number of data sets, but like-named variables in the data set must have the same type and length.

  8. If you concatenate the data sets below in the order shown, what is the value of Sale in observation 2 of the new data set?
    DataH
    ID Name
    1 Nay Rong
    2 Kelly Windsor
    3 Julio Meraz
    4 Richard Krabill
    DataI
    ID Sale
    1 $28,000
    2 $30,000
    2 $40,000
    3 $15,000
    3 $20,000
    3 $25,000
    4 $35,000
    DataJ
    ID Bonus
    1 $2,000
    2 $4,000
    3 $3,000
    4 $2,500

     a.   missing
     b.   $30,000
     c.   $40,000
     d.   you cannot concatenate these data sets

  9. Which of these programs correctly reads the data set DataK and creates the data set DataL?

     a.  
    data test.datak;
       set test.datal(drop=type);
       if count<35;
    run; 
     
     b.  
    data test.datal;
       set test.datak(drop=type);
       if type=1;
    run; 
     
     c.  
    data test.datal;
       merge test.datak(drop=type);
       if count<35;
    run; 
     
     d.  
    data test.datal;
       set test.datak(drop=type);
       if count<35;
    run;

  10. If you submit the following program, which variables appear in the new data set?
    data work.cardiac(drop=age group);
       set clinic.heart(keep=arterial cardiac urinary)
    clinic.fitness(keep=age weight oxygen group); if group=2 and age>40;
    run;

     a.   Arterial, Cardiac, Weight, Oxygen, Age
     b.   Arterial, Cardiac, Urinary, Weight, Oxygen
     c.   Age, Group
     d.   Age, Weight, Oxygen, Group



back||next

Terms of Use & Legal Information | Privacy Statement