By admin | December 23, 2009

SAS Certified Adv Programmer 130 Questions (37)

Given the following SAS data sets ONE and TWO:

ONE 
NUM CHAR1 
1   A1 
1   A2 
2   B1 
2   B2 
5   V

TWO 
NUM CHAR2
2   X1
2   X2 
3   Y
4   D

The following SAS program is submitted creating the output table THREE:

proc sql;
    create table three as select one.num, char1, char2 from one, two 
        where one.num = two.num;
quit;
THREE 
NUM CHAR1 CHAR2
2   B1    X1
2   B1    X2
2   B2    X1
2   B2    X2

Which one of the following DATA step programs creates an equivalent SAS data set THREE?

A.

data three;
    merge one two;
    by num;
run;

B.

data three;
    set one;
    set two;
    by num;
run;

merge one two;
    by num;
run;

C.

data three;
    set one;
    set two;
    by num;
run;
    by num;
run;

D.

data three;
    set one;
    do i = 1 to numobs;
        set two(rename = (num = num2)) point = i nobs = numobs;
        if num2 = num then output;
    end;
    drop num2;
run; 

6 comments | Add One

  1. admin - 12/23/2009 at 10:48 am

    D

  2. Chris - 05/5/2010 at 2:38 am

    shouldn’t “A” be the correct answer?

  3. SSK22 - 04/24/2012 at 10:18 am

    No, the answer provided by the admin is right. Merge handles missing and many-to-many matches differently.

  4. monica - 05/30/2012 at 10:22 am

    D is the answer I checked it

  5. ishuca - 07/24/2012 at 8:18 pm

    answer A is
    num char1 char2
    1 a1
    1 a2
    2 b1 x1
    2 b2 x2
    3 y
    4 d
    5 v
    correct answer is D

  6. Kamal KC - 09/18/2012 at 12:04 am

    No way, ANS is D. Pls check the SAS code sensibly.

Leave a Comment

Leave a Reply

Your email address will not be published.