ElearnSAS.com

ElearnSAS.com
SAS Learning Platform

Base SAS 104

The following SAS program is submitted:
data work.empsalary;
set work.people (in = inemp)
work.money (in = insal);
if insal and inemp;
run;
The SAS data set WORK.PEOPLE has 5 observations, and the data set WORK.MONEY has 7 observations.
How many observations will the data set WORK.EMPSALARY contain?
A. 0
B. 5
C. 7
D. 12
Click Comment link to get answer

16 comments:

  1. Replies
    1. This comment has been removed by the author.

      Delete
  2. Anonymous9:17 AM

    A. 0

    ReplyDelete
  3. Anonymous1:54 PM

    Why is it A?

    ReplyDelete
    Replies
    1. Anonymous6:42 PM

      Run the code:
      data work.people;
      input names $ ;
      datalines;
      Ramesh
      Suresh
      ;
      run;

      data work.money;
      input names $ ;
      datalines;
      Ramesh
      Suresh
      ;
      run;

      data work.empsalary;
      set work.people (in = inemp)
      work.money (in = insal);
      inemp_value = inemp;
      insal_value = insal;
      run;
      proc print data = work.empsalary;


      Obs names inemp_value insal_value
      1 Ramesh 1 0
      2 Suresh 1 0
      3 Ramesh 0 1
      4 Suresh 0 1

      if you see output the condition "if insal and inemp; " will never satisfy. Hence 0 observation.

      Delete
  4. Because in it a set statement not merge, so only inemp or insal can be true at a time.

    ReplyDelete
  5. bombomba12:17 AM

    Yes, like SAScert said, the answer is '0' observations because the statement 'merge' is not used. At this case, you are either inemp or insal, but not both.

    ReplyDelete
  6. Anonymous11:02 AM

    true...0 is the ans..

    ReplyDelete
  7. Anonymous3:25 PM

    so if the statement was re-written from an 'AND' to an 'OR' (if insal OR inemp), would this be allowable for SET statement?

    ReplyDelete
  8. yes you can change 'AND' to 'OR' but it will be same as regular set statment, so there is no need for OR.

    ReplyDelete
  9. Anonymous11:32 PM

    In 'SET', only one table is contributing in any one observation of resulting dataset therefore only one 'in=' variable can be true for such observation.

    ReplyDelete
  10. This Is Really Useful And Nices Information. เสือมังกรมือถือ
    This are such great articles. เสือมังกรมือถือ This articles can help you to make some new ideas.
    https://soccersurfer98.hatenablog.com/entry/2020/09/02/132139?_ga=2.193217001.552343305.1598844608-1286484823.1596077192 I appreciate for reading my blogs.

    ReplyDelete