BookmarkSubscribeRSS Feed
natluri
Calcite | Level 5

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.

5 REPLIES 5
ballardw
Super User

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.

 

natluri
Calcite | Level 5

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?

ballardw
Super User

@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).

natluri
Calcite | Level 5
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.
sabisw
SAS Employee

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

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 2035 views
  • 1 like
  • 3 in conversation