<?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: Proc SQL question? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-question/m-p/314771#M270833</link>
    <description>&lt;P&gt;a)/b):&lt;/P&gt;
&lt;P&gt;At minimum there is a typo at carat:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  select product.*, cost.unitcost, sales.quantity
                                       ^
  from product p, cost c, sale s
  where p.item = c.item and p.item = s.item;
quit;&lt;/PRE&gt;
&lt;P&gt;2)&lt;/P&gt;
&lt;P&gt;Why are you putting your data in sasuser? &amp;nbsp;Use work for wokring data:&lt;/P&gt;
&lt;PRE&gt;data ranch condo;
  set sasuser.houses;
  if style='RANCH' then output ranch;
  else if style='CONDO' then output condo;
run;
proc print data=condo;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 28 Nov 2016 09:38:25 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2016-11-28T09:38:25Z</dc:date>
    <item>
      <title>Proc SQL question?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-question/m-p/314713#M270829</link>
      <description>&lt;P&gt;Hello, &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Due to I don't have SAS at home, I wish someone could help me out for two questions below. &amp;nbsp;Many thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. &amp;nbsp;Which one is not right based on the following two PROC SQL program? &amp;nbsp;Why? &amp;nbsp;In my opinion, both are not correct.&lt;/P&gt;&lt;P class="m_6251547859479355590gmail-MsoListParagraphCxSpFirst"&gt;A.&lt;/P&gt;&lt;P class="m_6251547859479355590gmail-MsoListParagraphCxSpFirst"&gt;proc sql;&lt;/P&gt;&lt;P class="m_6251547859479355590gmail-MsoListParagraphCxSpMiddle"&gt;select product.*, cost.unitcost, sales.quantity&lt;/P&gt;&lt;P class="m_6251547859479355590gmail-MsoListParagraphCxSpMiddle"&gt;from product p, cost c, sale s&lt;/P&gt;&lt;P class="m_6251547859479355590gmail-MsoListParagraphCxSpMiddle"&gt;where p.item = c.item and p.item = s.item;&lt;/P&gt;&lt;P class="m_6251547859479355590gmail-MsoListParagraphCxSpMiddle"&gt;quit;&lt;/P&gt;&lt;P class="m_6251547859479355590gmail-MsoListParagraphCxSpMiddle"&gt;B.&amp;nbsp;&lt;/P&gt;&lt;P class="m_6251547859479355590gmail-MsoListParagraphCxSpMiddle"&gt;proc sql;&lt;/P&gt;&lt;P class="m_6251547859479355590gmail-MsoListParagraphCxSpMiddle"&gt;select p.*, cost.unitcost, sales.quantity&lt;/P&gt;&lt;P class="m_6251547859479355590gmail-MsoListParagraphCxSpMiddle"&gt;from product , cost , sale&lt;/P&gt;&lt;P class="m_6251547859479355590gmail-MsoListParagraphCxSpMiddle"&gt;where product.item = cost.item and product.item = sales.item;&lt;/P&gt;&lt;P class="m_6251547859479355590gmail-MsoListParagraphCxSpLast"&gt;quit;&lt;/P&gt;&lt;P class="m_6251547859479355590gmail-MsoListParagraphCxSpLast"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="m_6251547859479355590gmail-MsoListParagraphCxSpLast"&gt;2. Why&lt;SPAN&gt;&amp;nbsp;the PRINT procedure fails?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;229 data sasuser.ranch sasuser.condo / view = sasuser.ranch;&lt;/P&gt;&lt;P&gt;230 set sasuser.houses;&lt;/P&gt;&lt;P&gt;231 if style='RANCH' then output sauser.ranch;&lt;/P&gt;&lt;P&gt;232 else if style='CONDO' then output sasuser.condo;&lt;/P&gt;&lt;P&gt;233 run;&lt;/P&gt;&lt;P&gt;NOTE: DATA STEP view saved on file SASUSER.RANCH. NOTE:&lt;/P&gt;&lt;P&gt;A stored DATA STEP view cannot run under a different operating system.&lt;/P&gt;&lt;P&gt;234 235 proc print data = sasuser.condo;&lt;/P&gt;&lt;P&gt;ERROR: File sasuser.condo data does not exist.&lt;/P&gt;&lt;P&gt;236 run;&lt;/P&gt;&lt;P&gt;NOTE: The SAS system stopped processing this step because of errors.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2016 03:35:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-question/m-p/314713#M270829</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2016-11-28T03:35:48Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL question?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-question/m-p/314718#M270830</link>
      <description>&lt;P&gt;1. There's issues with both. Not sure if some are typos or what though&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. There must not have been any obs outputted to the condo dataset. Do the cases match? Comparisons are case sensitive.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2016 03:51:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-question/m-p/314718#M270830</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-11-28T03:51:33Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL question?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-question/m-p/314722#M270831</link>
      <description>&lt;P&gt;Hint for question 2: Try adding&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_; set sasuser.ranch(obs=1); run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;before calling proc print. Check the log messages.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2016 04:19:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-question/m-p/314722#M270831</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-11-28T04:19:46Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL question?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-question/m-p/314730#M270832</link>
      <description>&lt;P&gt;&lt;EM&gt;Due to I don't have SAS at home&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;There is a free SAS version available for non commercial use. &lt;A href="http://support.sas.com/software/products/university-edition/&amp;nbsp;" target="_blank"&gt;http://support.sas.com/software/products/university-edition/&amp;nbsp;&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2016 05:45:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-question/m-p/314730#M270832</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-11-28T05:45:39Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL question?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-question/m-p/314771#M270833</link>
      <description>&lt;P&gt;a)/b):&lt;/P&gt;
&lt;P&gt;At minimum there is a typo at carat:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  select product.*, cost.unitcost, sales.quantity
                                       ^
  from product p, cost c, sale s
  where p.item = c.item and p.item = s.item;
quit;&lt;/PRE&gt;
&lt;P&gt;2)&lt;/P&gt;
&lt;P&gt;Why are you putting your data in sasuser? &amp;nbsp;Use work for wokring data:&lt;/P&gt;
&lt;PRE&gt;data ranch condo;
  set sasuser.houses;
  if style='RANCH' then output ranch;
  else if style='CONDO' then output condo;
run;
proc print data=condo;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2016 09:38:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-question/m-p/314771#M270833</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-11-28T09:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL question?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-question/m-p/314823#M270834</link>
      <description>&lt;PRE&gt;proc sql;
  select product.*, cost.unitcost, sale.quantity
                                       ^
  from product p, cost c, sale s
  where p.item = c.item and p.item = s.item;
quit;&lt;/PRE&gt;&lt;P&gt;If the program is list as above, should it put "as" before "p", "c" and "s"? Or it could be omissed?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2016 14:42:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-question/m-p/314823#M270834</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2016-11-28T14:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL question?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-question/m-p/314827#M270835</link>
      <description>&lt;PRE&gt;  from product as p, cost as c, sale as s
  &lt;/PRE&gt;&lt;P&gt;like that? &amp;nbsp;or&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;  from product p, cost c, sale s
  &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;the above is working too.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2016 14:49:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-question/m-p/314827#M270835</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2016-11-28T14:49:53Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL question?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-question/m-p/314847#M270836</link>
      <description>&lt;P&gt;Many errors in B&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;B. 

proc sql;
select p.*, cost.unitcost, sales.quantity
       ^                       ^
from product , cost , sale

where product.item = cost.item and product.item = sales.item;
                                                      ^
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The syntax on select is dataset.variable (or an alias defined on the From clause) your P.* needs to reference a data set, you only have product, cost and sale. You also refer to sales.quantity SALES is not the same as SALE&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your example A has the SAME issue with Sale vs Sales though is likely to work (assuming the variable names are correct/present in the&amp;nbsp;data sets)&amp;nbsp;if you use:&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000" face="SAS Monospace" size="2"&gt;select&lt;/FONT&gt; &lt;FONT color="#804040" face="SAS Monospace" size="2"&gt;p.&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;*, c.unitcost, s.quantity&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;because you had defined the Aliases p, c and s.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2016 15:37:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-question/m-p/314847#M270836</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-11-28T15:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL question?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-question/m-p/314851#M270837</link>
      <description>&lt;P&gt;I would go through an SQL tutorial to understand some basic concepts such as aliasing. &amp;nbsp;In this:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  select product.*, cost.unitcost, sales.quantity
                                       ^
  from product p, cost c, sale s
  where p.item = c.item and p.item = s.item;
quit;&lt;/PRE&gt;
&lt;P&gt;there is a dataset called "sale" which you alias as "s", however in your select statement you use something called "sales" which matches neither a dataset nor an alias. &amp;nbsp;Is this some sort of training material you are working through?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2016 15:42:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-question/m-p/314851#M270837</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-11-28T15:42:41Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL question?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-question/m-p/314911#M270838</link>
      <description>&lt;P&gt;yes&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2016 18:11:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-question/m-p/314911#M270838</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2016-11-28T18:11:34Z</dc:date>
    </item>
  </channel>
</rss>

