<?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: Can I combine below 2 proc sqls into 1 proc sql or data step? pleases suggest how resolve this? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Can-I-combine-below-2-proc-sqls-into-1-proc-sql-or-data-step/m-p/838426#M331500</link>
    <description>&lt;P&gt;Example data of each of the input data set and expected result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also suggest that you check your syntax for the shown code. You have a , where there should be ; in the Proc statement,&lt;/P&gt;
&lt;P&gt;the comma before the ON is questionable, I suspect you are missing an "AND" in the where clauses and the Order by a variable not on the select will cause notes in the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The bit where both Proc SQL create the same data set, Test1, may also be a bit of an issue as I'm not sure what you expect after running this code.&lt;/P&gt;</description>
    <pubDate>Thu, 13 Oct 2022 15:39:11 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-10-13T15:39:11Z</dc:date>
    <item>
      <title>Can I combine below 2 proc sqls into 1 proc sql or data step? pleases suggest how resolve this?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-combine-below-2-proc-sqls-into-1-proc-sql-or-data-step/m-p/838409#M331492</link>
      <description>&lt;PRE class=""&gt;&lt;CODE class=""&gt;Proc &lt;SPAN class=""&gt;sql&lt;/SPAN&gt;,
    &lt;SPAN class=""&gt;create&lt;/SPAN&gt; &lt;SPAN class=""&gt;table&lt;/SPAN&gt; test1 &lt;SPAN class=""&gt;as&lt;/SPAN&gt; 
    &lt;SPAN class=""&gt;select&lt;/SPAN&gt; m1,f,&lt;SPAN class=""&gt;1&lt;/SPAN&gt;,l1,np1
    &lt;SPAN class=""&gt;from&lt;/SPAN&gt; &lt;SPAN class=""&gt;table&lt;/SPAN&gt; k.claimtable a
    inner &lt;SPAN class=""&gt;join&lt;/SPAN&gt; k.tab2 b,
    &lt;SPAN class=""&gt;ON&lt;/SPAN&gt;(a.m1&lt;SPAN class=""&gt;=&lt;/SPAN&gt;b.m1)
    &lt;SPAN class=""&gt;where a.pc in ('1234')&lt;BR /&gt;&lt;/SPAN&gt;    a.ser_date between '01jan2022'd and 31aug2022'd&lt;BR /&gt;    order by a.ser_date ;  &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; Proc &lt;SPAN class=""&gt;sql&lt;/SPAN&gt;,
    &lt;SPAN class=""&gt;create&lt;/SPAN&gt; &lt;SPAN class=""&gt;table&lt;/SPAN&gt; test1 &lt;SPAN class=""&gt;as&lt;/SPAN&gt; 
    &lt;SPAN class=""&gt;select&lt;/SPAN&gt; m1,f,&lt;SPAN class=""&gt;1&lt;/SPAN&gt;,l1,np1
    &lt;SPAN class=""&gt;from&lt;/SPAN&gt; &lt;SPAN class=""&gt;table&lt;/SPAN&gt; k.claimtable a
    inner &lt;SPAN class=""&gt;join&lt;/SPAN&gt; k.tab3 b,
    &lt;SPAN class=""&gt;ON&lt;/SPAN&gt;(a.m1&lt;SPAN class=""&gt;=&lt;/SPAN&gt;b.m1)
    &lt;SPAN class=""&gt;where a.pc in ('99999')&lt;BR /&gt;&lt;/SPAN&gt;    a.ser_date between '01jan2022'd and 31aug2022'd&lt;BR /&gt;    order by a.ser_date ;  &lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;CODE class=""&gt;we are joining proc sql's with two different tables (tab2,tab3) with 1 claims table to extract data for those procedure codes. &lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 14:41:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-combine-below-2-proc-sqls-into-1-proc-sql-or-data-step/m-p/838409#M331492</guid>
      <dc:creator>saskishore</dc:creator>
      <dc:date>2022-10-13T14:41:46Z</dc:date>
    </item>
    <item>
      <title>Re: Can I combine below 2 proc sqls into 1 proc sql or data step? pleases suggest how resolve this?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-combine-below-2-proc-sqls-into-1-proc-sql-or-data-step/m-p/838426#M331500</link>
      <description>&lt;P&gt;Example data of each of the input data set and expected result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also suggest that you check your syntax for the shown code. You have a , where there should be ; in the Proc statement,&lt;/P&gt;
&lt;P&gt;the comma before the ON is questionable, I suspect you are missing an "AND" in the where clauses and the Order by a variable not on the select will cause notes in the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The bit where both Proc SQL create the same data set, Test1, may also be a bit of an issue as I'm not sure what you expect after running this code.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 15:39:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-combine-below-2-proc-sqls-into-1-proc-sql-or-data-step/m-p/838426#M331500</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-10-13T15:39:11Z</dc:date>
    </item>
    <item>
      <title>Re: Can I combine below 2 proc sqls into 1 proc sql or data step? pleases suggest how resolve this?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-combine-below-2-proc-sqls-into-1-proc-sql-or-data-step/m-p/838438#M331506</link>
      <description>&lt;P&gt;Show some example input data and the results you want from that input.&lt;/P&gt;
&lt;P&gt;You are not saying where the selected variables are coming from.&amp;nbsp; Which ones are coming from CLAIM and which are coming from TAB2 or 3?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you looking for something like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select a.m1
   /*   , other variables from A */
        , coalesce(b.xxx,c.xxx) as xxx
   /*  Repeat for other variables that could come from TAB2 or TAB3 */
from claimtable
(where=(ser_date between '01JAN2022'd and '31AUG2022'd
       and pc in ('1234','99999')
)  a
left join tab2 b on a.m1=b.m1 and a.pc = '1234'
left join tab3 c on a.m1=c.m1 and a.pc = '99999'
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Oct 2022 16:38:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-combine-below-2-proc-sqls-into-1-proc-sql-or-data-step/m-p/838438#M331506</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-10-13T16:38:43Z</dc:date>
    </item>
    <item>
      <title>Re: Can I combine below 2 proc sqls into 1 proc sql or data step? pleases suggest how resolve this?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-combine-below-2-proc-sqls-into-1-proc-sql-or-data-step/m-p/838469#M331516</link>
      <description>&lt;P&gt;My best guess:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc sql;
    create table test1 as 
    (select a.ser_date, m1, f, 1 as aNumber, l1, np1
    from table k.claimtable as a
    inner join k.tab2 as b on a.m1 = b.m1
    where a.pc in ('1234') and a.ser_date between '01jan2022'd and 31aug2022'd)
	union all
	(select a.ser_date, m1, f, 1 as aNumber, l1, np1
    from table k.claimtable as a
    inner join k.tab3 as b on a.m1 = b.m1
    where a.pc in ('99999') and a.ser_date between '01jan2022'd and 31aug2022'd)
	order by ser_date;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Oct 2022 18:20:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-combine-below-2-proc-sqls-into-1-proc-sql-or-data-step/m-p/838469#M331516</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2022-10-13T18:20:57Z</dc:date>
    </item>
  </channel>
</rss>

