<?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: &amp;quot;Else&amp;quot; statement for PROC SQL when creating table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/quot-Else-quot-statement-for-PROC-SQL-when-creating-table/m-p/670544#M201317</link>
    <description>&lt;P&gt;To get you started:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select&amp;nbsp;Table1.*
     , Table2.Information1
  &amp;nbsp;&amp;nbsp; ,&amp;nbsp;Table2.Information2
from Table1
       left join 
     Table2
       on  Table1.Date &amp;gt;= Table2.Date1 
       and Table1.Date &amp;lt;= Table2.Date2 
       and Table1.ID    = Table2.ID    ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note how good formatting makes the code so much easier to read and vet.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 20 Jul 2020 23:21:33 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2020-07-20T23:21:33Z</dc:date>
    <item>
      <title>"Else" statement for PROC SQL when creating table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-Else-quot-statement-for-PROC-SQL-when-creating-table/m-p/670538#M201315</link>
      <description>&lt;P&gt;Hello everyone, i am using the following statement to integrate information from 2 different tables. Table1 with ~20000rows, and Table2 with ~2500rows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe that my code is correct because i am being able to merge the tables. However, the values that don't match the "where" statements are being deleted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any way to modify my code below to keep the information from Table1, and bring only the information from table 2 that matches the where statement without deleting the data. I mean, is there any way to do that using the else and keep statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When i run the following code y table 3 ends up with 10000 rows only. Tha`s OK because i do not expect that all rows match, but I rather prefer to have Table 3 with the 20000 original rows and the 2500 rows from table 2 that matched already included on it.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create Table 3 as select&lt;BR /&gt;Table2.Information1,&amp;nbsp;Table2.Information2, Table1.* from Table2, Table1&lt;BR /&gt;where Table1.Date &amp;gt;= Table2.Date1 and Table1.Date &amp;lt;= Table2.Date2 and&lt;BR /&gt;Table1.ID= Table2.ID;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wonder if there is any way to include the "else" "keep" here to fix this issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks guys.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jul 2020 00:06:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-Else-quot-statement-for-PROC-SQL-when-creating-table/m-p/670538#M201315</guid>
      <dc:creator>edison83</dc:creator>
      <dc:date>2020-07-20T00:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: "Else" statement for PROC SQL when creating table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-Else-quot-statement-for-PROC-SQL-when-creating-table/m-p/670544#M201317</link>
      <description>&lt;P&gt;To get you started:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select&amp;nbsp;Table1.*
     , Table2.Information1
  &amp;nbsp;&amp;nbsp; ,&amp;nbsp;Table2.Information2
from Table1
       left join 
     Table2
       on  Table1.Date &amp;gt;= Table2.Date1 
       and Table1.Date &amp;lt;= Table2.Date2 
       and Table1.ID    = Table2.ID    ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note how good formatting makes the code so much easier to read and vet.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jul 2020 23:21:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-Else-quot-statement-for-PROC-SQL-when-creating-table/m-p/670544#M201317</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-07-20T23:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: "Else" statement for PROC SQL when creating table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-Else-quot-statement-for-PROC-SQL-when-creating-table/m-p/670556#M201325</link>
      <description>WHERE filters your table by definition. If you do not specify the join type by default it becomes a cross join which is very inefficient. Explicitly specify your join and the fields you want to join on always is better practice in general. ChrisNZ solution changes your join from a cross join to a left join and then controls the join. If the join condition isn't met the rows from the left table are maintained and no fields from the other table are included.</description>
      <pubDate>Mon, 20 Jul 2020 03:13:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-Else-quot-statement-for-PROC-SQL-when-creating-table/m-p/670556#M201325</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-20T03:13:32Z</dc:date>
    </item>
    <item>
      <title>Re: "Else" statement for PROC SQL when creating table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-Else-quot-statement-for-PROC-SQL-when-creating-table/m-p/670654#M201360</link>
      <description>Thanks Chris, i see now that changing the structure is better.&lt;BR /&gt;&lt;BR /&gt;However, instead of 10000 rows now, table 3 has 13000 Browns...much better than the first one but i still don`t understand why it`s not keeping the original 20000 rows.&lt;BR /&gt;&lt;BR /&gt;I will work more with the data and let you know if i figure out something.&lt;BR /&gt;&lt;BR /&gt;Thanks for the help</description>
      <pubDate>Mon, 20 Jul 2020 13:59:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-Else-quot-statement-for-PROC-SQL-when-creating-table/m-p/670654#M201360</guid>
      <dc:creator>edison83</dc:creator>
      <dc:date>2020-07-20T13:59:03Z</dc:date>
    </item>
    <item>
      <title>Re: "Else" statement for PROC SQL when creating table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-Else-quot-statement-for-PROC-SQL-when-creating-table/m-p/670718#M201380</link>
      <description>&lt;P&gt;Up and running Chris, it`s working perfectly now!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the code&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jul 2020 16:12:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-Else-quot-statement-for-PROC-SQL-when-creating-table/m-p/670718#M201380</guid>
      <dc:creator>edison83</dc:creator>
      <dc:date>2020-07-20T16:12:30Z</dc:date>
    </item>
  </channel>
</rss>

