<?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 proc sql-Join in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-Join/m-p/481059#M124389</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;Please find following code in proc sql.&lt;/P&gt;&lt;P&gt;I want to ask please what type of join is done here?&lt;/P&gt;&lt;P&gt;Inner join? full join? left join? right join?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why If I write - &amp;nbsp; &amp;nbsp;on survey.Answer=survey2.Answer &amp;nbsp;I receive an error?&lt;/P&gt;&lt;P&gt;and it only works with - &amp;nbsp; where survey.Answer=survey2.Answer ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data survey;
    input State $ Answer $ @@;
    datalines;
NY YES NY YES NY YES NY YES NY YES NY YES NY NO  NY NO  NY NO  NC YES 
NC YES NC YES NC YES NC YES NC YES NC YES NC YES NC YES NC YES NC YES
NC YES NC YES NC YES NC YES NC YES NC YES NC YES NC YES NC YES NC NO
NC NO  NC NO  NC NO  NC NO  NC NO  NC NO  NC NO  NC NO  NC NO  NC NO
NC NO  NC NO  NC NO  NC NO  NC NO  NC NO  NC NO  NC NO  NC NO  NC NO
NC NO  NC NO  NC NO  PA YES PA YES PA YES PA YES PA YES PA YES PA YES
PA YES PA YES PA NO  PA NO  PA NO  PA NO  PA NO  PA NO  PA NO  PA NO  
PA NO  PA NO  PA NO  PA NO  PA NO  PA NO  PA NO  PA NO  PA NO  PA NO
VA YES VA YES VA YES VA YES VA YES VA YES VA YES VA YES VA YES VA YES
VA YES VA YES VA YES VA YES VA YES VA YES VA YES VA YES VA YES VA NO
VA NO  VA NO  VA NO  VA NO  VA NO  VA NO  VA NO  VA NO  VA NO  VA NO
VA NO  VA NO  VA NO  VA NO  VA NO  VA NO
;
Run;

proc sql;
   title1 'Survey Responses';
   select survey.Answer, survey.State,
                  count(*) as Count,
                  calculated Count/Subtotal as Percent format=percent8.2
   from survey,
        (select Answer, 
                 count(*) as Subtotal
                 from survey
                  group by Answer) as survey2
   where survey.Answer=survey2.Answer
   group by survey.Answer, survey.State;
quit;


 &lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 25 Jul 2018 09:19:43 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2018-07-25T09:19:43Z</dc:date>
    <item>
      <title>proc sql-Join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-Join/m-p/481059#M124389</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;Please find following code in proc sql.&lt;/P&gt;&lt;P&gt;I want to ask please what type of join is done here?&lt;/P&gt;&lt;P&gt;Inner join? full join? left join? right join?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why If I write - &amp;nbsp; &amp;nbsp;on survey.Answer=survey2.Answer &amp;nbsp;I receive an error?&lt;/P&gt;&lt;P&gt;and it only works with - &amp;nbsp; where survey.Answer=survey2.Answer ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data survey;
    input State $ Answer $ @@;
    datalines;
NY YES NY YES NY YES NY YES NY YES NY YES NY NO  NY NO  NY NO  NC YES 
NC YES NC YES NC YES NC YES NC YES NC YES NC YES NC YES NC YES NC YES
NC YES NC YES NC YES NC YES NC YES NC YES NC YES NC YES NC YES NC NO
NC NO  NC NO  NC NO  NC NO  NC NO  NC NO  NC NO  NC NO  NC NO  NC NO
NC NO  NC NO  NC NO  NC NO  NC NO  NC NO  NC NO  NC NO  NC NO  NC NO
NC NO  NC NO  NC NO  PA YES PA YES PA YES PA YES PA YES PA YES PA YES
PA YES PA YES PA NO  PA NO  PA NO  PA NO  PA NO  PA NO  PA NO  PA NO  
PA NO  PA NO  PA NO  PA NO  PA NO  PA NO  PA NO  PA NO  PA NO  PA NO
VA YES VA YES VA YES VA YES VA YES VA YES VA YES VA YES VA YES VA YES
VA YES VA YES VA YES VA YES VA YES VA YES VA YES VA YES VA YES VA NO
VA NO  VA NO  VA NO  VA NO  VA NO  VA NO  VA NO  VA NO  VA NO  VA NO
VA NO  VA NO  VA NO  VA NO  VA NO  VA NO
;
Run;

proc sql;
   title1 'Survey Responses';
   select survey.Answer, survey.State,
                  count(*) as Count,
                  calculated Count/Subtotal as Percent format=percent8.2
   from survey,
        (select Answer, 
                 count(*) as Subtotal
                 from survey
                  group by Answer) as survey2
   where survey.Answer=survey2.Answer
   group by survey.Answer, survey.State;
quit;


 &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Jul 2018 09:19:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-Join/m-p/481059#M124389</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-07-25T09:19:43Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql-Join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-Join/m-p/481067#M124394</link>
      <description>&lt;P&gt;Interesting question, never really thought about parallels.&amp;nbsp; The on keyword will not work as no join is specified.&amp;nbsp; The join is based on the where clause, so only data where answer is in both datasets would be output, so inner join effectively.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2018 09:49:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-Join/m-p/481067#M124394</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-07-25T09:49:31Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql-Join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-Join/m-p/481070#M124395</link>
      <description>&lt;P&gt;Thanks a lot.]&lt;/P&gt;&lt;P&gt;So it is just another way to write inner join .(using comma instead of writing inner join and using where instead of on).&lt;/P&gt;&lt;P&gt;It is an equivalent program&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   title1 'Survey Responses';
   select a.Answer, a.State,
                  count(*) as Count,
                  calculated Count/Subtotal as Percent format=percent8.2
   from survey  as  a 
         inner join (select Answer, 
                 count(*) as Subtotal
                 from survey
                  group by Answer) as b
   on a.Answer=b.Answer
   group by a.Answer, a.State;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Jul 2018 09:57:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-Join/m-p/481070#M124395</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-07-25T09:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql-Join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-Join/m-p/481074#M124397</link>
      <description>&lt;P&gt;Yes, should be.&amp;nbsp; You can always try it...&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2018 10:05:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-Join/m-p/481074#M124397</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-07-25T10:05:49Z</dc:date>
    </item>
  </channel>
</rss>

