<?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 Case, SQL Join in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Case-SQL-Join/m-p/323431#M71685</link>
    <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;May you help to corrrect the following statement ?&lt;/P&gt;&lt;P&gt;I tried to created variable PracticeSize based on variable num_pats during the two tables joins. &amp;nbsp;But it was not sucessful. And there is no error message.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you .&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table ads as&lt;BR /&gt;select a.*, b.num_pats,&lt;BR /&gt;case b.num_pats&lt;BR /&gt;when b.num_pats &amp;lt;= &amp;amp;q_1 then 'Small'&lt;BR /&gt;when &amp;amp;q_1 &amp;lt; b.num_pats &amp;lt;= &amp;amp;q_3 then 'Moderate'&lt;BR /&gt;when b.num_pats &amp;gt; &amp;amp;q_3 then 'Large'&lt;BR /&gt;end as PracticeSize&lt;BR /&gt;from demog_f as a&lt;BR /&gt;left join size as b&lt;BR /&gt;on a.PracticeID = b.PracticeID ;&lt;BR /&gt;quit;&lt;/P&gt;</description>
    <pubDate>Mon, 09 Jan 2017 18:35:30 GMT</pubDate>
    <dc:creator>Ivy</dc:creator>
    <dc:date>2017-01-09T18:35:30Z</dc:date>
    <item>
      <title>Case, SQL Join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Case-SQL-Join/m-p/323431#M71685</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;May you help to corrrect the following statement ?&lt;/P&gt;&lt;P&gt;I tried to created variable PracticeSize based on variable num_pats during the two tables joins. &amp;nbsp;But it was not sucessful. And there is no error message.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you .&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table ads as&lt;BR /&gt;select a.*, b.num_pats,&lt;BR /&gt;case b.num_pats&lt;BR /&gt;when b.num_pats &amp;lt;= &amp;amp;q_1 then 'Small'&lt;BR /&gt;when &amp;amp;q_1 &amp;lt; b.num_pats &amp;lt;= &amp;amp;q_3 then 'Moderate'&lt;BR /&gt;when b.num_pats &amp;gt; &amp;amp;q_3 then 'Large'&lt;BR /&gt;end as PracticeSize&lt;BR /&gt;from demog_f as a&lt;BR /&gt;left join size as b&lt;BR /&gt;on a.PracticeID = b.PracticeID ;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2017 18:35:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Case-SQL-Join/m-p/323431#M71685</guid>
      <dc:creator>Ivy</dc:creator>
      <dc:date>2017-01-09T18:35:30Z</dc:date>
    </item>
    <item>
      <title>Re: Case, SQL Join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Case-SQL-Join/m-p/323433#M71686</link>
      <description>&lt;P&gt;What do &amp;amp;q_1 and &amp;amp;q_3 resolve to?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Run the program with MPRINT and SYMBOLGEN on and check the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options symbolgen mprint;

proc sql;
create table ads as
select a.*, b.num_pats,

case 
when b.num_pats &amp;lt;= &amp;amp;q_1 then 'Small'
when &amp;amp;q_1 &amp;lt; b.num_pats &amp;lt;= &amp;amp;q_3 then 'Moderate'
when b.num_pats &amp;gt; &amp;amp;q_3 then 'Large'
end as PracticeSize

from demog_f as a
left join size as b
on a.PracticeID = b.PracticeID ;
quit;&lt;BR /&gt;&lt;BR /&gt;proc freq data=ads;&lt;BR /&gt;table practiceSize;&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also, what does not successful mean? That doesn't tell us what isn't working.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2017 18:44:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Case-SQL-Join/m-p/323433#M71686</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-01-09T18:44:12Z</dc:date>
    </item>
    <item>
      <title>Re: Case, SQL Join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Case-SQL-Join/m-p/323438#M71688</link>
      <description>&lt;P&gt;No Error in log, however, resulted generated was wrong,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Practice Cumulative&lt;BR /&gt;Size Frequency Frequency&lt;BR /&gt;-----------------------------------&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5404 &amp;nbsp; 5404&lt;BR /&gt;Small &amp;nbsp; 7 5411&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;84 proc sql;&lt;BR /&gt;585 create table ads as&lt;BR /&gt;586 select a.*, b.num_pats, 'cisplatin' as cohort ,&lt;BR /&gt;587 case b.num_pats&lt;BR /&gt;588 when b.num_pats &amp;lt;= &amp;amp;q_1 then 'Small'&lt;BR /&gt;SYMBOLGEN: Macro variable Q_1 resolves to 8&lt;BR /&gt;589 when &amp;amp;q_1 &amp;lt; b.num_pats &amp;lt;= &amp;amp;q_3 then 'Moderate'&lt;BR /&gt;SYMBOLGEN: Macro variable Q_1 resolves to 8&lt;BR /&gt;SYMBOLGEN: Macro variable Q_3 resolves to 38&lt;BR /&gt;590 when b.num_pats&lt;BR /&gt;SYMBOLGEN: Macro variable Q_3 resolves to 38&lt;BR /&gt;590! &amp;gt; &amp;amp;q_3 then 'Large'&lt;BR /&gt;591 end as PracticeSize&lt;BR /&gt;592 from drug1 as a&lt;BR /&gt;593 left join size as b&lt;BR /&gt;594 on a.PracticeID = b.PracticeID ;&lt;BR /&gt;NOTE: A CASE expression has no ELSE clause. Cases not accounted for by the WHEN clauses will&lt;BR /&gt;result in a missing value for the CASE expression.&lt;BR /&gt;NOTE: Table WORK.ADS created, with 5411 rows and 34 columns.&lt;/P&gt;&lt;P&gt;595 quit;&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;real time 0.12 seconds&lt;BR /&gt;cpu time 0.16 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;596 proc freq data = ads; tables PracticeSize ; run ;&lt;/P&gt;&lt;P&gt;NOTE: There were 5411 observations read from the data set WORK.ADS.&lt;BR /&gt;NOTE: The PROCEDURE FREQ printed page 7.&lt;BR /&gt;NOTE: PROCEDURE FREQ used (Total process time):&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;NOTE: Remote submit to D.__4018 complete.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2017 18:57:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Case-SQL-Join/m-p/323438#M71688</guid>
      <dc:creator>Ivy</dc:creator>
      <dc:date>2017-01-09T18:57:06Z</dc:date>
    </item>
    <item>
      <title>Re: Case, SQL Join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Case-SQL-Join/m-p/323443#M71690</link>
      <description>&lt;P&gt;How is it incorrect?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2017 19:11:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Case-SQL-Join/m-p/323443#M71690</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-01-09T19:11:30Z</dc:date>
    </item>
    <item>
      <title>Re: Case, SQL Join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Case-SQL-Join/m-p/323444#M71691</link>
      <description>&lt;P&gt;CASE should take WHEN clauses, but you have added an extra reference to b.num_pats right after the word CASE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2017 19:15:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Case-SQL-Join/m-p/323444#M71691</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-01-09T19:15:14Z</dc:date>
    </item>
  </channel>
</rss>

