<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Query using PROC SQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Query-using-PROC-SQL/m-p/116386#M24000</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 24 Jul 2012 09:50:31 GMT</pubDate>
    <dc:creator>Amir</dc:creator>
    <dc:date>2012-07-24T09:50:31Z</dc:date>
    <item>
      <title>Query using PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-using-PROC-SQL/m-p/116375#M23989</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've just started preparing for the SAS Advanced Certification and come through the first chapter of the SAS Prep Guide.&amp;nbsp; Below is one of the chapter 1 quizzes and I sort of disagree with the answer given in the book.&amp;nbsp; I picked &lt;STRONG&gt;'d'&lt;/STRONG&gt; because all columns are table-unique except for '&lt;STRONG&gt;Address', &lt;/STRONG&gt;so there is no ambiguous reference if we use '&lt;STRONG&gt;price.address&lt;/STRONG&gt;' to read column '&lt;STRONG&gt;Address&lt;/STRONG&gt;'.&amp;nbsp; To make sure, I tried running the code on some other databases and results are the same for '&lt;STRONG&gt;b&lt;/STRONG&gt;' and '&lt;STRONG&gt;d&lt;/STRONG&gt;', no errors were found.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anybody have any ideas on the choice of a correct answer to this question?&amp;nbsp; Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thong&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;A id="N85" name="N85"&gt;3. &lt;/A&gt;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P class="first-para" id="100-19"&gt;Complete the following PROC SQL query to select the columns &lt;STRONG class="bold"&gt;&lt;TT&gt;Address&lt;/TT&gt;&lt;/STRONG&gt; and &lt;STRONG class="bold"&gt;&lt;TT&gt;SqFeet&lt;/TT&gt;&lt;/STRONG&gt; from the table &lt;EM class="emphasis"&gt;List.Size&lt;/EM&gt; and to select &lt;STRONG class="bold"&gt;&lt;TT&gt;Price&lt;/TT&gt;&lt;/STRONG&gt; from the table &lt;EM class="emphasis"&gt;List.Price&lt;/EM&gt;. (Only the &lt;STRONG class="bold"&gt;&lt;TT&gt;Address&lt;/TT&gt;&lt;/STRONG&gt; column appears in both tables.)&lt;/P&gt;&lt;PRE class="literallayout" id="100-20"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc sql; _______________ where size.address =price.address; from list.size,list.price; &lt;/PRE&gt;&lt;OL class="orderedlist" style="list-style-type: lower-alpha;"&gt;&lt;LI&gt;&lt;TT&gt;select address,sqfeet,price&lt;/TT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;TT&gt;select size.address,sqfeet,price&lt;/TT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;TT&gt;select price.address,sqfeet,price&lt;/TT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;either b or c &lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="internaljump" name="answer.N85"&gt;&lt;STRONG&gt;3.&lt;/STRONG&gt;&lt;/A&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P class="first-para" id="100-86"&gt;Correct answer: b&lt;SPAN class="beginpage"&gt;&lt;A id="101" name="101"&gt;&lt;/A&gt;&lt;A id="IDX-24" name="IDX-24"&gt;&lt;/A&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P class="para" id="101-1"&gt;&lt;/P&gt;&lt;P class="last-para" id="101-2"&gt;The SELECT clause lists the columns from both tables to be queried. You must use a prefix with the &lt;STRONG class="bold"&gt;&lt;TT&gt;Address&lt;/TT&gt;&lt;/STRONG&gt; column because it appears in both tables. The prefix specifies the table from which you want the column to be read.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2012 22:51:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-using-PROC-SQL/m-p/116375#M23989</guid>
      <dc:creator>ThongNguyen</dc:creator>
      <dc:date>2012-07-23T22:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: Query using PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-using-PROC-SQL/m-p/116376#M23990</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you sure about the SQL step code?&amp;nbsp; The semi-colon after the WHERE clause will cause the FROM to be separated from the WHERE.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2012 23:01:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-using-PROC-SQL/m-p/116376#M23990</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2012-07-23T23:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: Query using PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-using-PROC-SQL/m-p/116377#M23991</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Answer d is 'either b or c' but c is impossible, because there is no table price. So d is not the right one.&lt;/P&gt;&lt;P&gt;Answer a is incorrect, because address exists on two tables, so the selection is not unique.&lt;/P&gt;&lt;P&gt;We are left with b.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Dorota Jarosz&amp;nbsp; Oops! Table price does exist. Sorry.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2012 23:20:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-using-PROC-SQL/m-p/116377#M23991</guid>
      <dc:creator>Dorota_Jarosz</dc:creator>
      <dc:date>2012-07-23T23:20:22Z</dc:date>
    </item>
    <item>
      <title>Re: Query using PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-using-PROC-SQL/m-p/116378#M23992</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If we can assume that the SQL step was actually stated something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql; _______________&lt;/P&gt;&lt;P&gt;from list.size,list.price&amp;nbsp; &lt;/P&gt;&lt;P&gt;where size.address =price.address;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would have also selected D.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2012 23:37:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-using-PROC-SQL/m-p/116378#M23992</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2012-07-23T23:37:33Z</dc:date>
    </item>
    <item>
      <title>Re: Query using PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-using-PROC-SQL/m-p/116379#M23993</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;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.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jul 2012 00:03:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-using-PROC-SQL/m-p/116379#M23993</guid>
      <dc:creator>Dorota_Jarosz</dc:creator>
      <dc:date>2012-07-24T00:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: Query using PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-using-PROC-SQL/m-p/116380#M23994</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Am I missing something here? "&lt;/P&gt;&lt;P&gt;&lt;STRONG class="bold"&gt;&lt;TT&gt;Address&lt;/TT&gt;&lt;/STRONG&gt; and &lt;STRONG class="bold"&gt;&lt;TT&gt;SqFeet&lt;/TT&gt;&lt;/STRONG&gt; from the table &lt;EM class="emphasis"&gt;List.Size", while c: &lt;/EM&gt;&lt;TT&gt;select price.address,sqfeet,price&lt;/TT&gt;&lt;/P&gt;&lt;P&gt;&lt;TT&gt;So that would leave 'b' as only correct answer?&lt;/TT&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;P&gt;&lt;TT&gt;Haikuo&lt;/TT&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jul 2012 01:41:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-using-PROC-SQL/m-p/116380#M23994</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-07-24T01:41:18Z</dc:date>
    </item>
    <item>
      <title>Re: Query using PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-using-PROC-SQL/m-p/116381#M23995</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="125170" __jive_macro_name="user" class="jive_macro jive_macro_user" href="https://communities.sas.com/"&gt;&lt;/A&gt;: I just copied and pasted.&amp;nbsp; And yes, I&amp;nbsp; picked '&lt;STRONG&gt;d&lt;/STRONG&gt;' as well, assuming there were no errors in with semicolons and clause order in the question, not in the choices.&amp;nbsp; This is an answer in the set of SAS solutions that I disagree with.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jul 2012 02:59:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-using-PROC-SQL/m-p/116381#M23995</guid>
      <dc:creator>ThongNguyen</dc:creator>
      <dc:date>2012-07-24T02:59:52Z</dc:date>
    </item>
    <item>
      <title>Re: Query using PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-using-PROC-SQL/m-p/116382#M23996</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="5068" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;: We have column '&lt;STRONG&gt;Address&lt;/STRONG&gt;' in table '&lt;STRONG&gt;price&lt;/STRONG&gt;' as well, so '&lt;STRONG&gt;c&lt;/STRONG&gt;' is also correct.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jul 2012 03:13:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-using-PROC-SQL/m-p/116382#M23996</guid>
      <dc:creator>ThongNguyen</dc:creator>
      <dc:date>2012-07-24T03:13:51Z</dc:date>
    </item>
    <item>
      <title>Re: Query using PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-using-PROC-SQL/m-p/116383#M23997</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, I am aware of that. However, from I can see from your problem request, let me repeat:&lt;/P&gt;&lt;P&gt;select the columns &lt;SPAN style="text-decoration: underline;"&gt;&lt;TT&gt;Address&lt;/TT&gt;&lt;/SPAN&gt; and &lt;STRONG class="bold"&gt;&lt;TT&gt;SqFeet&lt;/TT&gt;&lt;/STRONG&gt; from the table &lt;SPAN style="text-decoration: underline;"&gt;&lt;EM class="emphasis"&gt;List.Size&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;EM class="emphasis"&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;EM class="emphasis"&gt;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.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM class="emphasis"&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Still Confused.&lt;/P&gt;&lt;P&gt;&lt;EM class="emphasis"&gt;Haikuo&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM class="emphasis"&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jul 2012 03:24:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-using-PROC-SQL/m-p/116383#M23997</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-07-24T03:24:25Z</dc:date>
    </item>
    <item>
      <title>Re: Query using PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-using-PROC-SQL/m-p/116384#M23998</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It think literally it does not force you to use 'Size' table to reference to the 'Address' column in the SELECT clause .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jul 2012 03:32:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-using-PROC-SQL/m-p/116384#M23998</guid>
      <dc:creator>ThongNguyen</dc:creator>
      <dc:date>2012-07-24T03:32:17Z</dc:date>
    </item>
    <item>
      <title>Re: Query using PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-using-PROC-SQL/m-p/116385#M23999</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What a muddle!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Because the question specifically requests ADDRESS from SIZE, I think that's what they wanted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clearly, either the question or the proposed answer needs to be reworked.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jul 2012 03:36:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-using-PROC-SQL/m-p/116385#M23999</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2012-07-24T03:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: Query using PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-using-PROC-SQL/m-p/116386#M24000</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jul 2012 09:50:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-using-PROC-SQL/m-p/116386#M24000</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2012-07-24T09:50:31Z</dc:date>
    </item>
    <item>
      <title>Re: Query using PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-using-PROC-SQL/m-p/116387#M24001</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="807378" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;: It's not necessary that same-named columns in both tables contain same data, but same type of data.&amp;nbsp; If no matchings were found, outputs would have no records.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jul 2012 15:44:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-using-PROC-SQL/m-p/116387#M24001</guid>
      <dc:creator>ThongNguyen</dc:creator>
      <dc:date>2012-07-24T15:44:10Z</dc:date>
    </item>
    <item>
      <title>Re: Query using PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-using-PROC-SQL/m-p/116388#M24002</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is a thin line: what they WANT versus what gives a correct outcome. They stated:&lt;/P&gt;&lt;P&gt;"...to select the columns &lt;STRONG class="bold"&gt;&lt;TT&gt;Address&lt;/TT&gt;&lt;/STRONG&gt; and &lt;STRONG class="bold"&gt;&lt;TT&gt;SqFeet&lt;/TT&gt;&lt;/STRONG&gt; from the table &lt;EM class="emphasis"&gt;List.Size&lt;/EM&gt; and to select &lt;STRONG class="bold"&gt;&lt;TT&gt;Price&lt;/TT&gt;&lt;/STRONG&gt; from the table &lt;EM class="emphasis"&gt;List.Price&lt;/EM&gt;."&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jul 2012 21:19:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-using-PROC-SQL/m-p/116388#M24002</guid>
      <dc:creator>Dorota_Jarosz</dc:creator>
      <dc:date>2012-07-24T21:19:50Z</dc:date>
    </item>
  </channel>
</rss>

