<?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: SQL getting different results from data step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SQL-getting-different-results-from-data-step/m-p/867106#M342447</link>
    <description>&lt;P&gt;What kind of library is dat? SAS or a database? If in doubt, run&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname dat list;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 29 Mar 2023 19:12:52 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2023-03-29T19:12:52Z</dc:date>
    <item>
      <title>SQL getting different results from data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-getting-different-results-from-data-step/m-p/867088#M342439</link>
      <description>&lt;P&gt;I think the sql procedure should return the same number of observations the data step below, but it doesn't.&amp;nbsp; &amp;nbsp;Does anyone know why?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;28 proc sql;&lt;BR /&gt;29 create table check1 as select *&lt;BR /&gt;30 from dat.PECOS_dat(firstobs=2)&lt;BR /&gt;31 where profit_status3 ne '';&lt;BR /&gt;NOTE: Table WORK.CHECK1 created, with 1 rows and 19 columns.&lt;/P&gt;&lt;P&gt;32 quit;&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;real time 0.03 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;33&lt;BR /&gt;34 data check2;&lt;BR /&gt;35 set dat.PECOS_dat(firstobs=2);&lt;BR /&gt;36 if profit_Status3 ne '';&lt;BR /&gt;37 run;&lt;/P&gt;&lt;P&gt;NOTE: There were 7416 observations read from the data set DAT.PECOS_DAT.&lt;BR /&gt;NOTE: The data set WORK.CHECK2 has 2 observations and 19 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.02 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2023 18:02:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-getting-different-results-from-data-step/m-p/867088#M342439</guid>
      <dc:creator>Batman</dc:creator>
      <dc:date>2023-03-29T18:02:48Z</dc:date>
    </item>
    <item>
      <title>Re: SQL getting different results from data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-getting-different-results-from-data-step/m-p/867106#M342447</link>
      <description>&lt;P&gt;What kind of library is dat? SAS or a database? If in doubt, run&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname dat list;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 Mar 2023 19:12:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-getting-different-results-from-data-step/m-p/867106#M342447</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-03-29T19:12:52Z</dc:date>
    </item>
    <item>
      <title>Re: SQL getting different results from data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-getting-different-results-from-data-step/m-p/867117#M342450</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/9248"&gt;@Batman&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's not the difference between PROC SQL and DATA step, but the difference between WHERE and IF: The WHERE filter (be it in a PROC SQL or a DATA step) is applied&amp;nbsp;&lt;EM&gt;before&lt;/EM&gt; the &lt;FONT face="courier new,courier"&gt;firstobs=&lt;/FONT&gt; dataset option, whereas the subsetting IF is applied &lt;EM&gt;after&lt;/EM&gt; the dataset option. So, in the first case&amp;nbsp;&lt;FONT face="courier new,courier"&gt;firstobs=2&lt;/FONT&gt; removes one of the observations satisfying the WHERE condition&amp;nbsp;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;profit_status3 ne ''&lt;/FONT&gt;&amp;nbsp;from the result, unless there is none at all. The observation skipped with&amp;nbsp;&lt;FONT face="courier new,courier"&gt;firstobs=2&lt;/FONT&gt; in the second case might not satisfy the IF condition anyway.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Example:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input x profit_status3 $;
cards;
1 .
2 b
3 c
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2023 19:50:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-getting-different-results-from-data-step/m-p/867117#M342450</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2023-03-29T19:50:52Z</dc:date>
    </item>
  </channel>
</rss>

