SAS Base Certification – Question 2

Question 2: Given the SAS data set WORK.ONE:

 Id Char1
--- -----
182 M
190 N
250 O
720 P

and the SAS data set WORK.TWO:

 Id Char2
--- -----
182 Q
623 R
720 S

The following program is submitted:

 by Id;

What is the first observation in the SAS data set WORK.BOTH?


A.	Id Char1 Char2
--- ----- -----
182 M

B.	Id Char1 Char2
--- ----- -----
182 Q

C.	Id Char1 Char2
--- ----- -----
182 M Q

D.	Id Char1 Char2
--- ----- -----
720 P S

*The SAS certification sample problem and answer above are sourced from the official SAS sample questions page. All answer logs, data sets, output, and commentary are provided by this blog.

Correct Answer

Incorrect Answer

Click to see Answer Explanation below

thanks for your support


    Uer Sep 25, 2016

    I agree with C. Why isnt ‘D’ also the correct answer? Please explain, Thanks

      acrews7 Dec 28, 2016

      It completes in the order given. It asks for the first observation which would be the first observation line that is ran.

      Hasan Apr 11, 2017

      Because 720 P S is not the first observation

      Shubh Jul 30, 2017

      Because it has specifically asked for first observation.

      Paul Oct 10, 2017

      I created this code in SAS v9.4 as I was convinced that ‘C’ is incorrect. The result of the merge (proc print of BOTH dataset) is as follows:
      Obs Id Char1
      1 182 Q
      2 190 N
      3 250 O
      4 623 R
      5 720 S

    RD Oct 24, 2016

    IT asked for by id so 182 comes first than 720

    Arun Vaibhav Dec 03, 2016

    So SAS will not print 720 P S ?
    Because even that is also a match
    What if we want to print all the matches
    Rather than just first encounter,
    And why SAS prints only first match?
    Please explain.

    Michael Jul 31, 2017

    Usr you asked the question, that I first asked. Then I remembered (from past experience) to reread and consider what ‘output’ was being specified. As others mentioned the question is very specific in asking for the 1st obs.

    Aaron Mar 29, 2018

    Dataset One has “Char1” variable whereas dataset Two has “Char2” variable — they are different variable. It looks your result is based on same variable Char1 name.

    The following is results I observe which confirms that C is correct:

    Obs id char1 char2
    1 182 M Q
    2 190 N
    3 250 O
    4 623 R
    5 720 P S


Leave a Comment

Please keep in mind that comments are moderated and rel="nofollow" is in use. So, please do not use a spammy keyword or a domain as your name, or it will be deleted. Let us have a personal and meaningful conversation instead.