<?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: Problem with create table statement in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Problem-with-create-table-statement/m-p/324716#M21695</link>
    <description>One thing I don't understand about the filter. Extractdate while stored as a datetime field actually has only dates (the time element is all 0's). Datebegin_14 is a datetime field, that is it has hours etc.&lt;BR /&gt;&lt;BR /&gt;When I run  &lt;BR /&gt;where c.extractdate = "31Dec2016"d&lt;BR /&gt;&lt;BR /&gt;and c.datebegin_at_clo IS NULL&lt;BR /&gt;&lt;BR /&gt;and datebegin_14 &amp;gt;= "01Jan2016"d;&lt;BR /&gt;&lt;BR /&gt;I get exactly the same number of records as I get when I run &lt;BR /&gt;&lt;BR /&gt;where EXTRACTDATE ='12/31/2016'&lt;BR /&gt;and DATEBEGIN_AT_CLO IS NULL&lt;BR /&gt;and DATEBEGIN_14 &amp;gt;= '01/01/2016'&lt;BR /&gt;&lt;BR /&gt;in TSQL in the MS Server. Using datepart(datebegin_14) &amp;gt;= "01Jan2016"d; in SAS returns no values at all so my server must not support that.</description>
    <pubDate>Fri, 13 Jan 2017 21:40:32 GMT</pubDate>
    <dc:creator>noetsi</dc:creator>
    <dc:date>2017-01-13T21:40:32Z</dc:date>
    <item>
      <title>Problem with create table statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Problem-with-create-table-statement/m-p/324697#M21686</link>
      <description>&lt;P&gt;I am running the following code (which is connecting to large data bases maintained by our IT unit on the 2008 MS Server).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;create&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;table&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; work.tab2&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; c.customerid format=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;$char9.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,a.casenumber format=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;$char9.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;STRONG&gt;c.datebegin_14 format=&lt;/STRONG&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;date12.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;, c.statuscase format=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;$char9.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;, duration_14 format=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;best5.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; rimsrpt.rptcasesummary c&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;left&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;join&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; rimsrpt.rptauthorization &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; a &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;on&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; c.extractdate=a.extractdate&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; c.customerid=a.customerid&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; c.casenumber=a.casenumber &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;where&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; c.extractdate = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;"31Dec2016"d&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; c.datebegin_at_clo &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;IS&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; NULL&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; datebegin_14 &amp;gt;= &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;"01Jan2016"d&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;everything works fine except the&amp;nbsp;field datebegin_14. This field returns only asterisks rather than the actual data in the table. It is stored on our server as a datetime field, but it uses NULL to reflect missing values rather than the . SAS uses. I tried using a string format for it ($char9.) but that returns an error rather than just not reporting the correct results.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 20:55:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Problem-with-create-table-statement/m-p/324697#M21686</guid>
      <dc:creator>noetsi</dc:creator>
      <dc:date>2017-01-13T20:55:35Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with create table statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Problem-with-create-table-statement/m-p/324699#M21687</link>
      <description>&lt;P&gt;What returns if you remove the format entirely?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it's a datetime, you want a datetime format, not a date format.&lt;/P&gt;
&lt;P&gt;format=datetime. would be another option to try.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 20:57:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Problem-with-create-table-statement/m-p/324699#M21687</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-01-13T20:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with create table statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Problem-with-create-table-statement/m-p/324705#M21689</link>
      <description>&lt;P&gt;If datebegin_14 is a datetime, you will be selecting many more records than you would anticipate when using:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and datebegin_14 &amp;gt;= "01Jan2016"d;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your database permits, you could try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and datepart(datebegin_14) &amp;gt;= "01Jan2016"d;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Similar considerations would apply to extractdate, if that is a datetime.&amp;nbsp; Datetime values are measured in seconds, while dates are measured in days, so datetime values are much larger than date values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS displays formatted values as a series of asterisks when the value is too large to fit into the assigned format. &amp;nbsp;You will need to assign a datetime format to datebegin_14, and not a date format. &amp;nbsp;NULL values are not even being extracted, since they fail on the WHERE conditions ... so they are not the issue.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 21:06:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Problem-with-create-table-statement/m-p/324705#M21689</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-01-13T21:06:35Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with create table statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Problem-with-create-table-statement/m-p/324706#M21690</link>
      <description>&lt;P&gt;And make sure the database is giving you a SAS datetime (via the SAS/ACCESS engine) and not a native Microsoft datetime, which is different (measured in "ticks" and not in seconds).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If needed, &lt;A href="http://blogs.sas.com/content/sasdummy/2012/06/14/read-a-microsoft-date-time-value-into-a-sas-date-time-value/" target="_self"&gt;you can convert using this technique&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 21:07:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Problem-with-create-table-statement/m-p/324706#M21690</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2017-01-13T21:07:50Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with create table statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Problem-with-create-table-statement/m-p/324707#M21691</link>
      <description>&lt;P&gt;SAS displays all **** when the length or display space is insufficient to display the value. Since you are connecting to and MS SQL server it is very likely that the "date" variables actually are datetimes which convert when brought to SAS. SAS dates are numbers of days and datetimes are numbers of seconds.&lt;/P&gt;
&lt;P&gt;If you only want the date portion of the data then use the DATEPART function: Datepart(&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;c.datebegin_1) as datebegin&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data junk;
    /* x is a datetime variable*/
   x = '01JAN2017:00:00:00'dt;
   put "x displayed with a datetime format" x= datetime20.;
   put "x displayed with a date format" x= date9.;
   put "x displayed with a numeric format" x= best20.;
   y=datepart(x);
   put 'y is a date:' y= date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The confusion on the part of many database folks between dates and datetimes is pet peeve of mine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 21:10:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Problem-with-create-table-statement/m-p/324707#M21691</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-01-13T21:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with create table statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Problem-with-create-table-statement/m-p/324710#M21692</link>
      <description>&lt;P&gt;I am new here so the responses came in faster than I could read them. I wanted to thank everyone for responding.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;c.datebegin_14 format=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;datetime&lt;/FONT&gt; and the results showed up.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;extractdate used in the filter is listed as a datetime on the server, but actually only stored as a date. The way I filtered for it in the where statement is (other than a different SAS format) exactly how we do it the TQL used on the server. I am checking if the number of records in the server equal what SAS is pulling in.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the first time I have accessed the tables directly in SAS (until recently it was too slow to do this. We ran the data in the MS Server than exported it into SAS through excel which was very much less than ideal, but neccessary because we did not have the correct SAS ACCESS software to use ODBC until this week).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I mainly do statistical work in SAS so I am still learning PROC SQL which varies in important ways from the TSQL I know.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 21:16:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Problem-with-create-table-statement/m-p/324710#M21692</guid>
      <dc:creator>noetsi</dc:creator>
      <dc:date>2017-01-13T21:16:23Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with create table statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Problem-with-create-table-statement/m-p/324716#M21695</link>
      <description>One thing I don't understand about the filter. Extractdate while stored as a datetime field actually has only dates (the time element is all 0's). Datebegin_14 is a datetime field, that is it has hours etc.&lt;BR /&gt;&lt;BR /&gt;When I run  &lt;BR /&gt;where c.extractdate = "31Dec2016"d&lt;BR /&gt;&lt;BR /&gt;and c.datebegin_at_clo IS NULL&lt;BR /&gt;&lt;BR /&gt;and datebegin_14 &amp;gt;= "01Jan2016"d;&lt;BR /&gt;&lt;BR /&gt;I get exactly the same number of records as I get when I run &lt;BR /&gt;&lt;BR /&gt;where EXTRACTDATE ='12/31/2016'&lt;BR /&gt;and DATEBEGIN_AT_CLO IS NULL&lt;BR /&gt;and DATEBEGIN_14 &amp;gt;= '01/01/2016'&lt;BR /&gt;&lt;BR /&gt;in TSQL in the MS Server. Using datepart(datebegin_14) &amp;gt;= "01Jan2016"d; in SAS returns no values at all so my server must not support that.</description>
      <pubDate>Fri, 13 Jan 2017 21:40:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Problem-with-create-table-statement/m-p/324716#M21695</guid>
      <dc:creator>noetsi</dc:creator>
      <dc:date>2017-01-13T21:40:32Z</dc:date>
    </item>
  </channel>
</rss>

