<?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: Expression to convert Date9. to Datetime? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Expression-to-convert-Date9-to-Datetime/m-p/559805#M10390</link>
    <description>&lt;P&gt;Thanks for your quick response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I actually found this expression on here:&amp;nbsp;&lt;STRONG&gt;dhms (VALID_FROM_DTTM,0,0,0)&amp;nbsp;&lt;/STRONG&gt;and it was able to express my column (VALID_FROM_DTTM) as&amp;nbsp;&lt;STRONG&gt;06JUN2018:00:00:00.000 &lt;/STRONG&gt;but returns an error&amp;nbsp;&lt;STRONG&gt;WARNING: Apparent symbolic reference BUSINESSDATE_DTTM not resolved.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What does this error mean and how can I resolve it? I actually don't mind having my datetime in the format above with all zeros.&lt;/P&gt;</description>
    <pubDate>Fri, 17 May 2019 21:57:27 GMT</pubDate>
    <dc:creator>Soulbroda</dc:creator>
    <dc:date>2019-05-17T21:57:27Z</dc:date>
    <item>
      <title>Expression to convert Date9. to Datetime?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Expression-to-convert-Date9-to-Datetime/m-p/559803#M10388</link>
      <description>&lt;P&gt;I have a source file with it's date in the format below;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 407px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29605iD260FD63C01F8DDA/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;When loading it into my SAS table, I used the expression: "&lt;STRONG&gt;COMPRESS(BusinessDate, '-')"&amp;nbsp;&lt;/STRONG&gt;to remove the hyphen and got the date in the load table like below;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29608i565197BC980BA48A/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;In my Work job, I use the expression: "&lt;STRONG&gt;input(VALID_FROM_DTTM,yymmdd8.)"&amp;nbsp;&lt;/STRONG&gt;to convert the numeric values to a Date value to look like below;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29609i2866C25645655469/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;MY QUESTION&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I am trying to use this in a stage job that only accepts the date value in a datetime format. I have asked some guys in the office and I get the same response that I can't convert date to datetime. I have had some problems resolved here and was just thinking I should give it a shot. Is there a way I can get my VALID_FROM_DTTM in Datetime value?&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2019 21:46:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Expression-to-convert-Date9-to-Datetime/m-p/559803#M10388</guid>
      <dc:creator>Soulbroda</dc:creator>
      <dc:date>2019-05-17T21:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: Expression to convert Date9. to Datetime?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Expression-to-convert-Date9-to-Datetime/m-p/559804#M10389</link>
      <description>&lt;P&gt;if your date doesn't have a time attached to it as a datetime does it will not work as expected.&lt;/P&gt;
&lt;P&gt;you will always get all zero's for the time-part that you add to the date.&lt;/P&gt;
&lt;P&gt;remember the addition of nothing is nothing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2019 21:51:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Expression-to-convert-Date9-to-Datetime/m-p/559804#M10389</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-05-17T21:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: Expression to convert Date9. to Datetime?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Expression-to-convert-Date9-to-Datetime/m-p/559805#M10390</link>
      <description>&lt;P&gt;Thanks for your quick response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I actually found this expression on here:&amp;nbsp;&lt;STRONG&gt;dhms (VALID_FROM_DTTM,0,0,0)&amp;nbsp;&lt;/STRONG&gt;and it was able to express my column (VALID_FROM_DTTM) as&amp;nbsp;&lt;STRONG&gt;06JUN2018:00:00:00.000 &lt;/STRONG&gt;but returns an error&amp;nbsp;&lt;STRONG&gt;WARNING: Apparent symbolic reference BUSINESSDATE_DTTM not resolved.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What does this error mean and how can I resolve it? I actually don't mind having my datetime in the format above with all zeros.&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2019 21:57:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Expression-to-convert-Date9-to-Datetime/m-p/559805#M10390</guid>
      <dc:creator>Soulbroda</dc:creator>
      <dc:date>2019-05-17T21:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: Expression to convert Date9. to Datetime?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Expression-to-convert-Date9-to-Datetime/m-p/559808#M10391</link>
      <description>&lt;P&gt;If COMPRESS() worked on the variable then it is neither a DATE nor a DATETIME value.&amp;nbsp; Date values are stored as a number of days and Datetime values are stored as a number of seconds.&amp;nbsp; So they are both NUMERIC variables.&amp;nbsp; If the value has hyphens in it then it is a CHARACTER variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the INPUT() function to convert text into values.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The DHMS() (Days Hours Minutes Seconds) function can convert from date to datetime.&amp;nbsp; But you need to pick as time of day&amp;nbsp;during that day that you want. Typically the timepart is set to zero.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For both DATE and DATETIME values make sure to attach an appropriate format that will allow SAS to display the number in a way that humans will understand.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's run a little test to see how to do that.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  BusinessDate = '2018-06-06';
  ActualDate = input(BusinessDate,yymmdd10.);
  ActualDateTime = dhms(ActualDate,0,0,0);
  format ActualDate DATE9.  ActualDateTime DATETIME20.;
  put (_all_) (=);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;BusinessDate=2018-06-06 ActualDate=06JUN2018 ActualDateTime=06JUN2018:00:00:00&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2019 22:06:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Expression-to-convert-Date9-to-Datetime/m-p/559808#M10391</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-17T22:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: Expression to convert Date9. to Datetime?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Expression-to-convert-Date9-to-Datetime/m-p/559809#M10392</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/259392"&gt;@Soulbroda&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for your quick response.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I actually found this expression on here:&amp;nbsp;&lt;STRONG&gt;dhms (VALID_FROM_DTTM,0,0,0)&amp;nbsp;&lt;/STRONG&gt;and it was able to express my column (VALID_FROM_DTTM) as&amp;nbsp;&lt;STRONG&gt;06JUN2018:00:00:00.000 &lt;/STRONG&gt;but returns an error&amp;nbsp;&lt;STRONG&gt;WARNING: Apparent symbolic reference BUSINESSDATE_DTTM not resolved.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What does this error mean and how can I resolve it? I actually don't mind having my datetime in the format above with all zeros.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That error means that your code included the text &amp;amp;BUSINESSDATE_DTTM.&amp;nbsp; The ampersand is the trigger to the macro processor that you want to reference the value of a macro variable.&amp;nbsp; Your screen shots make it look like you values are in actual datasets, not in macro variables.&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2019 22:09:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Expression-to-convert-Date9-to-Datetime/m-p/559809#M10392</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-17T22:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: Expression to convert Date9. to Datetime?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Expression-to-convert-Date9-to-Datetime/m-p/559815#M10393</link>
      <description>&lt;P&gt;Looks like another case where SQL Server programmers are using the incorrect data type to define the date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;why carry extra weight in a column to store a datetime when a numerical value store the correct input?&amp;nbsp; This leads to confusion for the meaning of a datetime field.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I gave meds to the client on 25JAN2017:00:00:00.000 because the doctor placed the order at 25JAN2017:00:00:00.000&lt;/P&gt;
&lt;P&gt;how do you measure if the meds were give 24 minutes before the doctor placed the order and the patient died at 25JAN2017:00:25:00.000&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;stupid to store a bunch of 0's when there is no meaning to them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2019 22:37:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Expression-to-convert-Date9-to-Datetime/m-p/559815#M10393</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-05-17T22:37:56Z</dc:date>
    </item>
  </channel>
</rss>

