BookmarkSubscribeRSS Feed
ThongNguyen
Calcite | Level 5

I've just started preparing for the SAS Advanced Certification and come through the first chapter of the SAS Prep Guide.  Below is one of the chapter 1 quizzes and I sort of disagree with the answer given in the book.  I picked 'd' because all columns are table-unique except for 'Address', so there is no ambiguous reference if we use 'price.address' to read column 'Address'.  To make sure, I tried running the code on some other databases and results are the same for 'b' and 'd', no errors were found.

Does anybody have any ideas on the choice of a correct answer to this question?  Thanks.

Thong

3.   

Complete the following PROC SQL query to select the columns Address and SqFeet from the table List.Size and to select Price from the table List.Price. (Only the Address column appears in both tables.)

        proc sql; _______________ where size.address =price.address; from list.size,list.price; 
  1. select address,sqfeet,price
  2. select size.address,sqfeet,price
  3. select price.address,sqfeet,price
  4. either b or c

3.  

Correct answer: b

The SELECT clause lists the columns from both tables to be queried. You must use a prefix with the Address column because it appears in both tables. The prefix specifies the table from which you want the column to be read.

13 REPLIES 13
ArtC
Rhodochrosite | Level 12

Are you sure about the SQL step code?  The semi-colon after the WHERE clause will cause the FROM to be separated from the WHERE.

ThongNguyen
Calcite | Level 5

: I just copied and pasted.  And yes, I  picked 'd' as well, assuming there were no errors in with semicolons and clause order in the question, not in the choices.  This is an answer in the set of SAS solutions that I disagree with.

Dorota_Jarosz
Obsidian | Level 7

Answer d is 'either b or c' but c is impossible, because there is no table price. So d is not the right one.

Answer a is incorrect, because address exists on two tables, so the selection is not unique.

We are left with b.

Message was edited by: Dorota Jarosz  Oops! Table price does exist. Sorry.

ArtC
Rhodochrosite | Level 12

If we can assume that the SQL step was actually stated something like:

proc sql; _______________

from list.size,list.price 

where size.address =price.address;

I would have also selected D.

Dorota_Jarosz
Obsidian | Level 7

Art: You are right, I misread the problem. Table price does exist. In this case b and c are equivalent, so d is the correct answer.

Haikuo
Onyx | Level 15

Am I missing something here? "

Address and SqFeet from the table List.Size", while c: select price.address,sqfeet,price

So that would leave 'b' as only correct answer?


Haikuo

ThongNguyen
Calcite | Level 5

: We have column 'Address' in table 'price' as well, so 'c' is also correct.

Haikuo
Onyx | Level 15

Yes, I am aware of that. However, from I can see from your problem request, let me repeat:

select the columns Address and SqFeet from the table List.Size


So even table 'price' does have included variable 'address', but to comply with the request, variable 'address' has to be from table 'size', therefore 'c' is NOT correct.


Still Confused.

Haikuo


ThongNguyen
Calcite | Level 5

It think literally it does not force you to use 'Size' table to reference to the 'Address' column in the SELECT clause .

TomKari
Onyx | Level 15

What a muddle!

I think you're all correct, but in different ways. I do agree that b and c are equivalent, but only because of the WHERE clause. Because the question lists b as the right answer, and the justification is the need to distinguish address because it is in both tables, I'm speculating that the sample SQL statement was pulled in from a different question, and the person drafting the question didn't pay attention to the WHERE clause.

Because the question specifically requests ADDRESS from SIZE, I think that's what they wanted.

Clearly, either the question or the proposed answer needs to be reworked.

Tom

Amir
PROC Star

Further, just because two columns have the same name on different tables it doesn't necessarily mean they hold the same data. E.g., one Address might be a contact address, and the other Address might be an invoice address, so it would be important to follow the spec (or question in this case) to ensure the correct column / data is used.

Regards,

Amir.

ThongNguyen
Calcite | Level 5

: It's not necessary that same-named columns in both tables contain same data, but same type of data.  If no matchings were found, outputs would have no records.

Dorota_Jarosz
Obsidian | Level 7

It is a thin line: what they WANT versus what gives a correct outcome. They stated:

"...to select the columns Address and SqFeet from the table List.Size and to select Price from the table List.Price."

Maybe they subscribe to the "do always what your boss wants and how he wants it" philosophy? If this is so, I would not like to work for them.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 13 replies
  • 2071 views
  • 4 likes
  • 6 in conversation