07-23-2012 06:51 PM
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.
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;
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.
07-23-2012 10:59 PM
07-23-2012 07:20 PM
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.
07-23-2012 07:37 PM
If we can assume that the SQL step was actually stated something like:
proc sql; _______________
where size.address =price.address;
I would have also selected D.
07-23-2012 09:41 PM
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?
07-23-2012 11:24 PM
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.
07-23-2012 11:36 PM
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.
07-24-2012 05:50 AM
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.
07-24-2012 11:44 AM
07-24-2012 05:19 PM
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.