DATA Step, Macro, Functions and more

SAS Prep Guide SAS 9 4th edition question on Ch 13 quiz

Reply
New Contributor
Posts: 3

SAS Prep Guide SAS 9 4th edition question on Ch 13 quiz

Hello,

 

I have a question on Ch 13 quiz, number 6 of the SAS Prep Guide SAS 9 4th Edition.

 

Why is the answer not a) instead of c) seems like C) actually has an extra unmatched observation? Can anyone help?

Suppose you merge data sets Health.Set1 and Health.Set2 below: Which output does the following program create? data work.merged; merge health.set1( in = in1) health.set2( in = in2); by id; if in1 and in2; run; proc print data = work.merged; run;

Institute, SAS. SAS Certification Prep Guide: Base Programming for SAS9, Fourth Edition (Kindle Locations 7517-7521). SAS Institute. Kindle Edition.

Super User
Posts: 13,950

Re: SAS Prep Guide SAS 9 4th edition question on Ch 13 quiz

Since many of us are not going to have the prep guide you should post 1) the data sets involved in the form of a data step, 2) the response categories.

Also post code in a code box opened with the forum {I} menu icon.

Example:

data work.merged; 
   merge health.set1( in = in1) 
         health.set2( in = in2)
   ; 
   by id; 
   if in1 and in2; 
run; 
proc print data = work.merged; 
run;

which is much easier to read.

 

The statement

   if in1 and in2; 

is going to restrict the output data set to those that only have matching values for ID. In1 is true if the current record is from the first set, In2 is true if the current record also has a contribution from the second set. Since the data matches on the variable ID the statement is true only when the record has a contribution from both sets and the record is output.

 

New Contributor
Posts: 3

Re: SAS Prep Guide SAS 9 4th edition question on Ch 13 quiz

SASque1.jpgSASque2.jpg

 

The appendix answer que states that the answer should be C, and I believe it should be A. Is it wrong in the book? If not, why?

Super User
Posts: 13,950

Re: SAS Prep Guide SAS 9 4th edition question on Ch 13 quiz


@natluri wrote:

 

 

The appendix answer que states that the answer should be C, and I believe it should be A. Is it wrong in the book? If not, why?


The font in the pictures is too small for me to read.

I suggest creating the two data sets and running the code.

Then compare your result to the answers.

 

When you get data steps to create the input data sets post them and we likely can provide additional details.

 

Also provide why you think it should be A).

New Contributor
Posts: 3

Re: SAS Prep Guide SAS 9 4th edition question on Ch 13 quiz

The publisher confirmed that I was correct and there was an error in the
book. Thanks. There should only be 6 matched observations.

You should be able to zoom out in the photos. Thank you though.
SAS Employee
Posts: 6

Re: SAS Prep Guide SAS 9 4th edition question on Ch 13 quiz

Hi @natluri,

 

We apologize for the error in the book. The correct answer is A, and not C. The DATA step uses the IN= data set option and the subsetting IF statements to exclude unmatched observations from the output data set.

 

We are currently updating our content updates page to reflect the necessary corrections in the Base Certification 4th edition. Once we have pushed the changes to the page, they will be available at the following link:  Base Certification 4th Edition Content Updates Page

 

Best Regards,
Samantha

Ask a Question
Discussion stats
  • 5 replies
  • 145 views
  • 1 like
  • 3 in conversation