ElearnSAS.com

ElearnSAS.com
SAS Learning Platform

Base sas 103

The contents of two SAS data sets named EMPLOYEE and SALARY are listed below: (Question updated)
How many observation are in EMPLSAL dataset

data emplsal;
merge employee (in=ine) salary(in=ins);
by name;
if ine and ins;
run;
Choices are
A. 4
B. 3
c. 2
D. 1

EMPLOYEE

SALARY

NAME

AGE

NAME

SALARY

Bruce

30

Bruce

40000

Dan

35

Bruce

35000



Dan

37000



Dan

.


22 comments:

  1. Replies
    1. what if it is:

      data work.empsalary;
      merge work.empployee(in=inemp)
      work.salary(in = insal);
      byname;
      if inemp OR insal; // OR instead of AN
      run;

      Delete
    2. Anonymous10:20 PM

      In this example, Same. 4 obs

      Delete
  2. Anonymous10:58 AM

    Bruce 30 40000
    Bruce 30 35000
    Dan 35 37000
    Dan 35 .

    ReplyDelete
  3. Anonymous9:26 AM

    data employee;
    input name $ salary;
    datalines;
    Bruce 40000
    Bruce 35000
    Dan 37000
    Dan .
    ;
    run;
    data salary;
    input name $ age;
    datalines;
    Bruce 30
    Dan 35
    ;
    run;
    data emplsal;
    merge employee (in=ine) salary(in=ins);
    by name;
    if ine=0 and ins=0;
    run;
    proc print data=emplsal;
    run;

    ReplyDelete
    Replies
    1. NIRMAL KUMAR3:39 AM

      (if ine=0 and ins=0 )should be changed to (if ine and ins)

      Delete
  4. Anonymous11:45 AM

    why you have to insert this statement? Do we needed to run? you are just confusing us. And you want us to fail in first shot?

    if ine=0 and ins=0;

    ReplyDelete
  5. Anonymous7:39 AM

    yeah that above first person is really confusing us.Please use some sense before you post anything or just know what you are posting!

    ReplyDelete
  6. Elango2:00 AM

    Answer is A (4)

    ReplyDelete
  7. merge employee (in=ine) salary(in=ins);

    i dont understand this statement man :(

    please help any one?

    ReplyDelete
  8. Unlike most variables, IN= variables are temporary, existing only during the current DATA step. SAS gives the IN= variables a value of 0 or 1. A value of 1 means that data set did contribute to the current observation, and a value of 0 means the data set did not contribute.
    In above question, DAN and BRUCE are included in both data set so condition of [if ine and ins;] is true so output will be 4 obs.

    ReplyDelete
    Replies
    1. Anonymous9:36 AM

      Unknown,

      I still don't quite understand why the correct answer is 4 obs (although I know 4 is the right answer). It seems to me that when SAS reads the last two lines in the data sets, EMPLOYEE does not contain any values for name or age, so INE should = 0 then and the condition would fail to hold, in which case no observations would be written for the last two data lines. Can you please explain why my thinking is incorrect here?

      Thanks

      Delete
    2. Consider this:

      data work.ds1;
      merge work.ds2 (in=X) work.ds3 (in=Y);
      by id;

      1. When in=X and in=Y --> Exact merge. The data set is appended without any condition.

      2. Only in=X --> Left inner merge. All the observations in ds2 and those common to ds2 and ds3 are merged. Rest are ignored.

      3. Only in=Y ---> Right inner merge. All the observations in ds3 and those common to ds2 and ds3 are merged. Rest are ignored.

      4. in=0 and in = Y -->Right outer merge. Only the observations in ds3 are merged.

      5. in = X and in=0 --> Left outer merge. Only the observations on d2 are merged.

      Hope this helps :)

      Delete
    3. In this question, the type of the merge is exact merge, since in=ine and in=ins. We do not check any conditions i.e. we do not bother what observations are common to work.ds2 and work.ds3. We simply merge all the observations from both the datasets and write it to ds1.

      Delete
    4. nice explanation...thank you

      Delete
    5. if ine and ins;
      run;
      this is a condition for inner join, where observations in both dataset must be common, it checks condition.

      Delete
  9. This comment has been removed by the author.

    ReplyDelete
  10. Anonymous11:59 PM

    thanks for the explanation Kruti

    ReplyDelete
  11. For SAS certification latest and exact exam questions contact us at completeexamcollection@gmail.com.
    Refer our blog for more details http://completeexamcollection.blogspot.in

    ReplyDelete