<?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: SAS vs MS SQL record count in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-vs-MS-SQL-record-count/m-p/673302#M202523</link>
    <description>&lt;P&gt;There are lots of options for what could be going wrong.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would recommend you make a small test query which replicates the problem, and is something you would be able to share.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might also check the counts you get from just select * from both tables, and make sure those match.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, UNION will (by default) return distinct values.&amp;nbsp; You might change to UNION ALL and see if they will match.&amp;nbsp; I don't know MS SQL server that well, I suppose it's possible to set a SQL server database as case-insensitive, which could lead to SQL server treating more values as duplicates than SAS would.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Jul 2020 20:17:04 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2020-07-29T20:17:04Z</dc:date>
    <item>
      <title>SAS vs MS SQL record count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-vs-MS-SQL-record-count/m-p/673260#M202496</link>
      <description>&lt;P&gt;hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i run a query in MS SQL where the query selects all records from 4 tables and unions them. Result set is then 249236 records&lt;/P&gt;&lt;P&gt;I copied the same code in SAS and placed it in the PROC SQL command yet i get 286966 records. This is&amp;nbsp; a difference of&amp;nbsp;37736 records and the code is the exact same. Do you know why?&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2020 18:40:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-vs-MS-SQL-record-count/m-p/673260#M202496</guid>
      <dc:creator>Citrine10</dc:creator>
      <dc:date>2020-07-29T18:40:59Z</dc:date>
    </item>
    <item>
      <title>Re: SAS vs MS SQL record count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-vs-MS-SQL-record-count/m-p/673264#M202499</link>
      <description>&lt;P&gt;Can you post the code for each including the LIBNAME statements?&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2020 18:54:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-vs-MS-SQL-record-count/m-p/673264#M202499</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-07-29T18:54:04Z</dc:date>
    </item>
    <item>
      <title>Re: SAS vs MS SQL record count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-vs-MS-SQL-record-count/m-p/673265#M202500</link>
      <description>there is no lib.&lt;BR /&gt;&lt;BR /&gt;SAS code:&lt;BR /&gt;proc sql;&lt;BR /&gt;select name from Table1&lt;BR /&gt;union&lt;BR /&gt;select name from Table2&lt;BR /&gt;;quit;&lt;BR /&gt;&lt;BR /&gt;SQL code:&lt;BR /&gt;select name from Table1&lt;BR /&gt;union&lt;BR /&gt;select name from Table2</description>
      <pubDate>Wed, 29 Jul 2020 18:58:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-vs-MS-SQL-record-count/m-p/673265#M202500</guid>
      <dc:creator>Citrine10</dc:creator>
      <dc:date>2020-07-29T18:58:26Z</dc:date>
    </item>
    <item>
      <title>Re: SAS vs MS SQL record count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-vs-MS-SQL-record-count/m-p/673270#M202502</link>
      <description>Then you're reading from your work library not the server so the expectation that the results are the same is incorrect.</description>
      <pubDate>Wed, 29 Jul 2020 19:06:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-vs-MS-SQL-record-count/m-p/673270#M202502</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-29T19:06:35Z</dc:date>
    </item>
    <item>
      <title>Re: SAS vs MS SQL record count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-vs-MS-SQL-record-count/m-p/673273#M202504</link>
      <description>&lt;P&gt;I dont think i understand as i connect directly to SQL server from SAS&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2020 19:10:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-vs-MS-SQL-record-count/m-p/673273#M202504</guid>
      <dc:creator>Citrine10</dc:creator>
      <dc:date>2020-07-29T19:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: SAS vs MS SQL record count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-vs-MS-SQL-record-count/m-p/673276#M202506</link>
      <description>&lt;P&gt;To&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;'s point, there is always a Lib in SAS.&amp;nbsp; If it's not coded, then it's WORK by default.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For your SAS code, can you post everything from the PROC SQL to the QUIT?&lt;/P&gt;
&lt;P&gt;For your SQL server code, can you post actual code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2020 19:11:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-vs-MS-SQL-record-count/m-p/673276#M202506</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-07-29T19:11:22Z</dc:date>
    </item>
    <item>
      <title>Re: SAS vs MS SQL record count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-vs-MS-SQL-record-count/m-p/673280#M202508</link>
      <description>I am unable to post the actual code as its confidential. what code be the difference in record count?</description>
      <pubDate>Wed, 29 Jul 2020 19:14:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-vs-MS-SQL-record-count/m-p/673280#M202508</guid>
      <dc:creator>Citrine10</dc:creator>
      <dc:date>2020-07-29T19:14:58Z</dc:date>
    </item>
    <item>
      <title>Re: SAS vs MS SQL record count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-vs-MS-SQL-record-count/m-p/673286#M202513</link>
      <description>1. Your expectation that they should be the same is incorrect because of an underlying difference in the data timeliness&lt;BR /&gt;2. You counted things incorrectly&lt;BR /&gt;3. You have deleted observations in the SQL database that are being counted&lt;BR /&gt;4. The code isn't the same between the processes, but you think it is.</description>
      <pubDate>Wed, 29 Jul 2020 19:24:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-vs-MS-SQL-record-count/m-p/673286#M202513</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-29T19:24:27Z</dc:date>
    </item>
    <item>
      <title>Re: SAS vs MS SQL record count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-vs-MS-SQL-record-count/m-p/673289#M202514</link>
      <description>&lt;P&gt;I'm sorry but i do not get what you are saying. Please elaborate&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2020 19:28:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-vs-MS-SQL-record-count/m-p/673289#M202514</guid>
      <dc:creator>Citrine10</dc:creator>
      <dc:date>2020-07-29T19:28:19Z</dc:date>
    </item>
    <item>
      <title>Re: SAS vs MS SQL record count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-vs-MS-SQL-record-count/m-p/673302#M202523</link>
      <description>&lt;P&gt;There are lots of options for what could be going wrong.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would recommend you make a small test query which replicates the problem, and is something you would be able to share.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might also check the counts you get from just select * from both tables, and make sure those match.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, UNION will (by default) return distinct values.&amp;nbsp; You might change to UNION ALL and see if they will match.&amp;nbsp; I don't know MS SQL server that well, I suppose it's possible to set a SQL server database as case-insensitive, which could lead to SQL server treating more values as duplicates than SAS would.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2020 20:17:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-vs-MS-SQL-record-count/m-p/673302#M202523</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2020-07-29T20:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: SAS vs MS SQL record count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-vs-MS-SQL-record-count/m-p/673303#M202524</link>
      <description>&lt;P&gt;Simplify your problem by doing row counts on single tables in SQL Server and in SAS then compare results.&lt;/P&gt;
&lt;P&gt;Identify which tables show a different row counts - all or just some?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2020 20:20:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-vs-MS-SQL-record-count/m-p/673303#M202524</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-07-29T20:20:21Z</dc:date>
    </item>
    <item>
      <title>Re: SAS vs MS SQL record count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-vs-MS-SQL-record-count/m-p/673369#M202563</link>
      <description>&lt;P&gt;hi thank you for the suggestions. i did a ccomparison and i see that the time is pulling with the date, thus there are multiple records.&lt;/P&gt;&lt;P&gt;How do i get only the date from a datetime SQL column?&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2020 08:28:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-vs-MS-SQL-record-count/m-p/673369#M202563</guid>
      <dc:creator>Citrine10</dc:creator>
      <dc:date>2020-07-30T08:28:09Z</dc:date>
    </item>
    <item>
      <title>Re: SAS vs MS SQL record count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-vs-MS-SQL-record-count/m-p/673388#M202576</link>
      <description>It might be due to NULL and Missing value defined in SAS and DB.&lt;BR /&gt;In any DB like MS SQL , Null is different from MISSING, but SAS take both as the same value for the sake of compatibility .</description>
      <pubDate>Thu, 30 Jul 2020 12:08:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-vs-MS-SQL-record-count/m-p/673388#M202576</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-07-30T12:08:04Z</dc:date>
    </item>
    <item>
      <title>Re: SAS vs MS SQL record count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-vs-MS-SQL-record-count/m-p/673391#M202578</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/338030"&gt;@Citrine10&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;hi thank you for the suggestions. i did a ccomparison and i see that the time is pulling with the date, thus there are multiple records.&lt;/P&gt;
&lt;P&gt;How do i get only the date from a datetime SQL column?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I am not sure why MS-SQL would consider two different datetime values as being the same just because they occur on the same date, but in SAS code you can use the DATEPART() function to convert a datetime value (number of seconds) into a date value (number of days).&amp;nbsp; Make sure to change the format attached since displaying a date value as if it was a datetime value will make all reasonable dates look like they are some time early in the morning of 01JAN1960.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also change all the datetime values to the datetime value for the start of the day by using the INTNX() function with the DTDATE interval.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2020 12:50:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-vs-MS-SQL-record-count/m-p/673391#M202578</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-07-30T12:50:50Z</dc:date>
    </item>
  </channel>
</rss>

