<?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 in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL/m-p/145250#M38581</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thanks for the reply&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I made the corrections to my code.&lt;/P&gt;&lt;P&gt;Even after removing the create table and insert into ...........I just get the results of HAC1 ...I am missing results of HAC2 from the&amp;nbsp; tempHAC dataset&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 17 Jun 2014 20:52:41 GMT</pubDate>
    <dc:creator>robertrao</dc:creator>
    <dc:date>2014-06-17T20:52:41Z</dc:date>
    <item>
      <title>PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL/m-p/145248#M38579</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;I have problems connecting these two pieces of code into ONE TABLE&lt;/P&gt;&lt;P&gt;Could some one help me solve this problem??&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;/*--HAC1*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;PROC SQL; &lt;BR /&gt;CREATE TABLE tempHAC AS&lt;BR /&gt;SELECT&lt;BR /&gt;'HAC1' AS Measure,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dat.Cal_Yr, &lt;BR /&gt;dat.Cal_Mo_Order, &lt;BR /&gt;COUNT(acc.HospitalAccountID) AS HaC_Count&lt;BR /&gt;FROM dwaprv.FACT_HospitalAccount AS acc,&lt;BR /&gt;dwaprv.FACT_HospitalAccountDiagnosis AS Diag,&lt;BR /&gt;dwaprv.DIM_Date AS dat,&lt;BR /&gt;dwaprv.DIM_Diagnosis AS ddiag&lt;BR /&gt;where acc.HospitalAccountID = diag.HospitalAccountID and &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; acc.DateDischargeKey = dat.DateKey and &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; diag.DiagnosisKey = ddiag.DiagnosisKey and &lt;BR /&gt;diag.Line ne 1 and&lt;BR /&gt;diag.DX_POA_YNU IN ("N","U") and&lt;BR /&gt;acc.DateDischargeKey &amp;gt;= &amp;amp;BegDate &lt;BR /&gt;AND acc.DateDischargeKey &amp;lt;= &amp;amp;EndDate&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AND ddiag.ICD9_Code IN (&amp;nbsp; &lt;BR /&gt;SELECT hacd.DX_Code &lt;BR /&gt;FROM dwaprv.REF_HACDiagnosis AS hacd &lt;BR /&gt;WHERE hacd.HAC_Description = 'HAC1')/*--('998.4','998.7')*/&lt;BR /&gt;AND EncounterTypeKey IN (1, 12, 13, 14, 15)&lt;BR /&gt;GROUP BY dat.Cal_Yr, dat.Cal_Mo_Order&lt;BR /&gt;ORDER BY dat.Cal_Yr, dat.Cal_Mo_Order&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;/*--HAC2*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT &lt;BR /&gt;'HAC2' AS Measure, &lt;BR /&gt;dat.Cal_Yr, &lt;BR /&gt;dat.Cal_Mo_Order, &lt;BR /&gt;COUNT(acc.HospitalAccountID) AS HAC_Count&lt;BR /&gt;FROM dwaprv.FACT_HospitalAccount AS acc,&lt;BR /&gt;dwaprv.FACT_HospitalAccountDiagnosis AS Diag,&lt;BR /&gt;dwaprv.DIM_Date AS dat,&lt;BR /&gt;dwaprv.DIM_Diagnosis AS ddiag&lt;BR /&gt;where acc.HospitalAccountID = diag.HospitalAccountID &lt;BR /&gt;&amp;nbsp; and acc.DateDischargeKey = dat.DateKey&lt;BR /&gt;&amp;nbsp; and diag.DiagnosisKey = ddiag.DiagnosisKey&lt;BR /&gt;&amp;nbsp; and diag.Line ne 1&lt;BR /&gt;&amp;nbsp; AND diag.DX_POA_YNU IN ('N','U')&lt;BR /&gt;&amp;nbsp; AND acc.DateDischargeKey &amp;gt;= &amp;amp;BegDate&lt;BR /&gt;&amp;nbsp; AND acc.DateDischargeKey &amp;lt;= &amp;amp;EndDate&lt;BR /&gt;&amp;nbsp; AND ddiag.ICD9_Code IN (&lt;BR /&gt;SELECT hacd.DX_Code &lt;BR /&gt;FROM dwaprv.REF_HACDiagnosis AS hacd &lt;BR /&gt;WHERE hacd.HAC_Description = 'HAC2')&amp;nbsp; /*--('999.1')*/&lt;BR /&gt;AND EncounterTypeKey IN (1, 12, 13, 14, 15)&lt;BR /&gt;GROUP BY dat.Cal_Yr, dat.Cal_Mo_Order&lt;BR /&gt;ORDER BY dat.Cal_Yr, dat.Cal_Mo_Order&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;quit&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jun 2014 20:33:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL/m-p/145248#M38579</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2014-06-17T20:33:29Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL/m-p/145249#M38580</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What exactly do you want. That second proc doesn't make sense, why do you have create table and insert into. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jun 2014 20:42:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL/m-p/145249#M38580</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-06-17T20:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL/m-p/145250#M38581</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thanks for the reply&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I made the corrections to my code.&lt;/P&gt;&lt;P&gt;Even after removing the create table and insert into ...........I just get the results of HAC1 ...I am missing results of HAC2 from the&amp;nbsp; tempHAC dataset&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jun 2014 20:52:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL/m-p/145250#M38581</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2014-06-17T20:52:41Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL/m-p/145251#M38582</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I suggest creating two separate tables and then appending them via proc append or proc sql union or a data step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set hac1 hac2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jun 2014 20:56:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL/m-p/145251#M38582</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-06-17T20:56:39Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL/m-p/145252#M38583</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Okie.&lt;/P&gt;&lt;P&gt;so we had to create tables sperately and then append them!!!&lt;/P&gt;&lt;P&gt;I cant do for example HAC1-HAC10 together in PROC SQL under one create statement??&lt;/P&gt;&lt;P&gt;IS that right??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jun 2014 20:59:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL/m-p/145252#M38583</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2014-06-17T20:59:51Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL/m-p/145253#M38584</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can, but you'd have to rework your query which is more work than *I* feel like doing. Perhaps someone else can help &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jun 2014 21:04:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL/m-p/145253#M38584</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-06-17T21:04:42Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL/m-p/145254#M38585</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could use a UNION or UNION ALL statement to append the tables using PROC SQL. The difference between UNION and UNION ALL is that UNION ALL will return duplicates if they exist. In the following example, I've used UNION ALL. Note I haven't checked to make sure that the number of columns and column names in both SELECT statements are the same (they must be the same). Code is untested.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL; &lt;BR /&gt;CREATE TABLE tempHAC AS&lt;/P&gt;&lt;P&gt;SELECT&lt;BR /&gt;'HAC1' AS Measure,&lt;/P&gt;&lt;P&gt;dat.Cal_Yr, &lt;BR /&gt;dat.Cal_Mo_Order, &lt;BR /&gt;COUNT(acc.HospitalAccountID) AS HaC_Count&lt;BR /&gt;FROM dwaprv.FACT_HospitalAccount AS acc,&lt;BR /&gt;dwaprv.FACT_HospitalAccountDiagnosis AS Diag,&lt;BR /&gt;dwaprv.DIM_Date AS dat,&lt;BR /&gt;dwaprv.DIM_Diagnosis AS ddiag&lt;BR /&gt;where acc.HospitalAccountID = diag.HospitalAccountID and &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; acc.DateDischargeKey = dat.DateKey and &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; diag.DiagnosisKey = ddiag.DiagnosisKey and &lt;BR /&gt;diag.Line ne 1 and&lt;BR /&gt;diag.DX_POA_YNU IN ("N","U") and&lt;BR /&gt;acc.DateDischargeKey &amp;gt;= &amp;amp;BegDate &lt;BR /&gt;AND acc.DateDischargeKey &amp;lt;= &amp;amp;EndDate&lt;/P&gt;&lt;P&gt; AND ddiag.ICD9_Code IN (&amp;nbsp; &lt;BR /&gt;SELECT hacd.DX_Code &lt;BR /&gt;FROM dwaprv.REF_HACDiagnosis AS hacd &lt;BR /&gt;WHERE hacd.HAC_Description = 'HAC1')/*--('998.4','998.7')*/&lt;BR /&gt;AND EncounterTypeKey IN (1, 12, 13, 14, 15)&lt;BR /&gt;GROUP BY dat.Cal_Yr, dat.Cal_Mo_Order&lt;/P&gt;&lt;P&gt;UNION ALL&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT &lt;BR /&gt;'HAC2' AS Measure, &lt;BR /&gt;dat.Cal_Yr, &lt;BR /&gt;dat.Cal_Mo_Order, &lt;BR /&gt;COUNT(acc.HospitalAccountID) AS HAC_Count&lt;BR /&gt;FROM dwaprv.FACT_HospitalAccount AS acc,&lt;BR /&gt;dwaprv.FACT_HospitalAccountDiagnosis AS Diag,&lt;BR /&gt;dwaprv.DIM_Date AS dat,&lt;BR /&gt;dwaprv.DIM_Diagnosis AS ddiag&lt;BR /&gt;where acc.HospitalAccountID = diag.HospitalAccountID &lt;BR /&gt;&amp;nbsp; and acc.DateDischargeKey = dat.DateKey&lt;BR /&gt;&amp;nbsp; and diag.DiagnosisKey = ddiag.DiagnosisKey&lt;BR /&gt;&amp;nbsp; and diag.Line ne 1&lt;BR /&gt;&amp;nbsp; AND diag.DX_POA_YNU IN ('N','U')&lt;BR /&gt;&amp;nbsp; AND acc.DateDischargeKey &amp;gt;= &amp;amp;BegDate&lt;BR /&gt;&amp;nbsp; AND acc.DateDischargeKey &amp;lt;= &amp;amp;EndDate&lt;BR /&gt;&amp;nbsp; AND ddiag.ICD9_Code IN (&lt;BR /&gt;SELECT hacd.DX_Code &lt;BR /&gt;FROM dwaprv.REF_HACDiagnosis AS hacd &lt;BR /&gt;WHERE hacd.HAC_Description = 'HAC2')&amp;nbsp; /*--('999.1')*/&lt;BR /&gt;AND EncounterTypeKey IN (1, 12, 13, 14, 15)&lt;BR /&gt;GROUP BY dat.Cal_Yr, dat.Cal_Mo_Order&lt;BR /&gt;ORDER BY dat.Cal_Yr, dat.Cal_Mo_Order&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jun 2014 22:10:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL/m-p/145254#M38585</guid>
      <dc:creator>Fugue</dc:creator>
      <dc:date>2014-06-17T22:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL/m-p/145255#M38586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Did you try just combining them into one statement?&lt;/P&gt;&lt;P&gt;Replace these lines:&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG&gt;ORDER BY dat.Cal_Yr, dat.Cal_Mo_Order&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="background-color: transparent; font-family: arial, helvetica, sans-serif; font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="background-color: transparent; font-family: arial, helvetica, sans-serif; font-size: 10pt; line-height: 1.5em;"&gt;with&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;UNION&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jun 2014 23:41:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL/m-p/145255#M38586</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-06-17T23:41:24Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL/m-p/145256#M38587</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like you are running the same query twice and are only modifying the value of the first variable and the WHERE clause.&lt;/P&gt;&lt;P&gt;If that is true then why do you need two queries at all?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;PROC&lt;/STRONG&gt; &lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;SQL&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;CREATE&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;TABLE&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; tempHAC &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;AS&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;SELECT&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; hacd.HAC_Description &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;AS&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; Measure&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , dat.Cal_Yr&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , dat.Cal_Mo_Order&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , COUNT(acc.HospitalAccountID) &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;AS&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; HaC_Count&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;FROM&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; dwaprv.FACT_HospitalAccount &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;AS&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; acc&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , dwaprv.FACT_HospitalAccountDiagnosis &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;AS&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; Diag&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , dwaprv.DIM_Date &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;AS&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; dat&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , dwaprv.DIM_Diagnosis &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;AS&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; ddiag&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , dwaprv.REF_HACDiagnosis &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;AS&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; hacd&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;where&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; acc.HospitalAccountID = diag.HospitalAccountID&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; acc.DateDischargeKey = dat.DateKey&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; diag.DiagnosisKey = ddiag.DiagnosisKey&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; diag.Line ne &lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; diag.DX_POA_YNU &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;IN&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; (&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;"N"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;"U"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;) &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; acc.DateDischargeKey &amp;gt;= &amp;amp;BegDate &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; acc.DateDischargeKey &amp;lt;= &amp;amp;EndDate&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; ddiag.ICD9_Code = hacd.DX_Code &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; hacd.HAC_Description &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;in&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; (&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;'HAC1'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;'HAC2'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;and&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green; background: white;"&gt;/* ?? Which Table ?? */&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; EncounterTypeKey &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;IN&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; (&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;, &lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;12&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;, &lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;13&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;, &lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;14&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;, &lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;15&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;GROUP&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;BY&lt;/SPAN&gt; &lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;,&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;2&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;,&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;3&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;ORDER&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;BY&lt;/SPAN&gt; &lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;,&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;2&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;,&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;3&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;quit&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jun 2014 23:59:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL/m-p/145256#M38587</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-06-17T23:59:02Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL/m-p/145257#M38588</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;It was very good to know the technique.&lt;/P&gt;&lt;P&gt;But In my case from HAC1-HAC10 the conditions differ.&lt;/P&gt;&lt;P&gt;In the above example HAC1 and HAC2 includes only Diagnosis codes difference between them&lt;/P&gt;&lt;P&gt;Code was lengthy so I could not fit them all in.....&lt;/P&gt;&lt;P&gt;there are two tables: REF_HACDiagnosis tables containing Diagnoses ranging from HAC1-HAC10...also we have REF_HACProcedure tables containing Procedures labeled as values from HAC1 -HAC10 also&lt;/P&gt;&lt;P&gt;for some HACS only Diagnoses was considered (like shown above) and some HACS had to take into account both Diagnoses and Procedures&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think UNION ALL is the key take home message!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also what is the meaning of GROUP BY 1 2 3????&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please correct&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Jun 2014 16:47:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL/m-p/145257#M38588</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2014-06-18T16:47:45Z</dc:date>
    </item>
  </channel>
</rss>

