<?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: How to populate date and datetime values under one variable without imputing time when time miss in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-populate-date-and-datetime-values-under-one-variable/m-p/456891#M115793</link>
    <description>&lt;P&gt;As I said in the previous post on this question:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/Date-time-informat-that-works-when-the-date-time-lengths-are/m-p/456523#M115643" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/Date-time-informat-that-works-when-the-date-time-lengths-are/m-p/456523#M115643&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;(Which you failed to get back to me on)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is quite simple.&amp;nbsp; Dates, times, datetimes are numbers, dates are number of days since cutoff, time is number of seconds since midnight, datetime is number of seconds since cuttoff.&amp;nbsp; So if you want a number that number needs to reflect the data which is stored, either date, time, or datetime.&amp;nbsp; You cannot store the number for date, then the number for datetime in one variable, this is not possible.&amp;nbsp; Either the variable contains date/time numbers or it contains date numbers.&amp;nbsp; This is also why, when applying a format, that format applies to every row in the variable, so if you say display as datetime, then all values will either be datetime or missing.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, from that you can only have one or the other in terms of a numeric variable.&lt;/P&gt;
&lt;P&gt;You could of course switch it over an use a character variable, much like you have in your given example.&amp;nbsp; As that is text - and does not reflect any internal storage - it can contain anything you like, hence why ISO dates are text.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once again, numeric dates, times, datetimes need to contain all parts to be valid numeric variables.&lt;/P&gt;</description>
    <pubDate>Tue, 24 Apr 2018 14:37:50 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-04-24T14:37:50Z</dc:date>
    <item>
      <title>How to populate date and datetime values under one variable without imputing time when time missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-populate-date-and-datetime-values-under-one-variable/m-p/456869#M115784</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some one from support helped me in the similar issue but that code is not getting the output i need in this issue. As specs changed so I have to update it.&lt;/P&gt;
&lt;P&gt;I need to derive a numeric variable 'b' without imputing time when time is missing. I tried a few ways but did not get what i need.&lt;/P&gt;
&lt;P&gt;Please sugest. Thank you&lt;/P&gt;
&lt;P&gt;ouput needed;&lt;/P&gt;
&lt;P&gt;b&amp;nbsp;&lt;/P&gt;
&lt;P&gt;01SEP17:15:10:00&lt;/P&gt;
&lt;P&gt;04SEP17&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
  input a $16.;
datalines;
2017-09-01T15:10
2017-09-04
;
run;&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2018 14:01:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-populate-date-and-datetime-values-under-one-variable/m-p/456869#M115784</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2018-04-24T14:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate date and datetime values under one variable without imputing time when time miss</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-populate-date-and-datetime-values-under-one-variable/m-p/456880#M115787</link>
      <description>&lt;P&gt;Convert to an appropriate format depending on the length of a.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data one;&lt;BR /&gt;&amp;nbsp; format a datetime20.; input a E8601DT20.;&lt;BR /&gt;datalines;&lt;BR /&gt;2017-09-01T15:10&lt;BR /&gt;2017-09-04&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data two;&lt;BR /&gt;&amp;nbsp; format b datetime20.; input b E8601DN. ;&lt;BR /&gt;datalines;&lt;BR /&gt;2017-09-01T15:10&lt;BR /&gt;2017-09-04&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2018 14:24:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-populate-date-and-datetime-values-under-one-variable/m-p/456880#M115787</guid>
      <dc:creator>tomrvincent</dc:creator>
      <dc:date>2018-04-24T14:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate date and datetime values under one variable without imputing time when time miss</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-populate-date-and-datetime-values-under-one-variable/m-p/456891#M115793</link>
      <description>&lt;P&gt;As I said in the previous post on this question:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/Date-time-informat-that-works-when-the-date-time-lengths-are/m-p/456523#M115643" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/Date-time-informat-that-works-when-the-date-time-lengths-are/m-p/456523#M115643&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;(Which you failed to get back to me on)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is quite simple.&amp;nbsp; Dates, times, datetimes are numbers, dates are number of days since cutoff, time is number of seconds since midnight, datetime is number of seconds since cuttoff.&amp;nbsp; So if you want a number that number needs to reflect the data which is stored, either date, time, or datetime.&amp;nbsp; You cannot store the number for date, then the number for datetime in one variable, this is not possible.&amp;nbsp; Either the variable contains date/time numbers or it contains date numbers.&amp;nbsp; This is also why, when applying a format, that format applies to every row in the variable, so if you say display as datetime, then all values will either be datetime or missing.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, from that you can only have one or the other in terms of a numeric variable.&lt;/P&gt;
&lt;P&gt;You could of course switch it over an use a character variable, much like you have in your given example.&amp;nbsp; As that is text - and does not reflect any internal storage - it can contain anything you like, hence why ISO dates are text.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once again, numeric dates, times, datetimes need to contain all parts to be valid numeric variables.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2018 14:37:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-populate-date-and-datetime-values-under-one-variable/m-p/456891#M115793</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-04-24T14:37:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate date and datetime values under one variable without imputing time when time miss</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-populate-date-and-datetime-values-under-one-variable/m-p/456900#M115796</link>
      <description>&lt;P&gt;Thanks to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/144199"&gt;@tomrvincent&lt;/a&gt;&amp;nbsp;I have learned also new informats for me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It can be done in the same step in any of the next two examples:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
  input a $16.;
  if length(a) = 10 &lt;BR /&gt;     then my_dt = input(substr(a,1,10), E8601DN10.);
     else my_dt = input(a, E8601DT16.);
datalines;
2017-09-01T15:10
2017-09-04
;
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or alternatively by:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
  input a $16.;
  if substr(a,11,1) = 'T' &lt;BR /&gt;     then my_dt = input(substr(a,1,10), E8601DN10.);
     else my_dt = input(a, E8601DT16.);
datalines;
2017-09-01T15:10
2017-09-04
;
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2018 14:52:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-populate-date-and-datetime-values-under-one-variable/m-p/456900#M115796</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2018-04-24T14:52:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate date and datetime values under one variable without imputing time when time miss</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-populate-date-and-datetime-values-under-one-variable/m-p/456988#M115829</link>
      <description>&lt;P&gt;Glad I could help.&amp;nbsp; Please feel free to mark my post as a solution so that I get an extra mug of mead in SAS Valhalla. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2018 17:45:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-populate-date-and-datetime-values-under-one-variable/m-p/456988#M115829</guid>
      <dc:creator>tomrvincent</dc:creator>
      <dc:date>2018-04-24T17:45:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate date and datetime values under one variable without imputing time when time miss</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-populate-date-and-datetime-values-under-one-variable/m-p/457006#M115837</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;, according to documentation I have, having a date in a form of yyyy-mm-dd&amp;nbsp;&lt;/P&gt;
&lt;P&gt;using informat&amp;nbsp;&amp;nbsp;&lt;CODE class="  language-sas"&gt;E8601DN10. will assume time 00:00:00 and create a datetime variable.&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class="  language-sas"&gt;Please check me.&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2018 18:20:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-populate-date-and-datetime-values-under-one-variable/m-p/457006#M115837</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2018-04-24T18:20:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate date and datetime values under one variable without imputing time when time miss</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-populate-date-and-datetime-values-under-one-variable/m-p/457178#M115891</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;.&amp;nbsp; You are indeed correct. When reading the data using this informat it does impute the missing 00:00:00.&amp;nbsp; However I thought from the posters original post that they wanted to display the datetime information after reading as two different date formats, which is a different matter.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Apr 2018 08:20:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-populate-date-and-datetime-values-under-one-variable/m-p/457178#M115891</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-04-25T08:20:33Z</dc:date>
    </item>
  </channel>
</rss>

