<?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: Datapart and Timepart functions in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Datapart-and-Timepart-functions/m-p/460779#M117150</link>
    <description>&lt;P&gt;OK, I played around with the excel file and figured out that it will work if I right justify the datetime column in excel. It doesn't appear differently in the imported SAS file (still left justified), but now the datepart and timepart work.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 08 May 2018 17:51:39 GMT</pubDate>
    <dc:creator>sarahsasuser</dc:creator>
    <dc:date>2018-05-08T17:51:39Z</dc:date>
    <item>
      <title>Datapart and Timepart functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datapart-and-Timepart-functions/m-p/460762#M117141</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to use the datepart and timepart functions to extract the date and times from 1 variable called admitdatetime. For example if the value of admitdatetime is 14MAR06:12:15:00 then date=14MAR06 and time=12:15. Further, I would like to create a variable called day that tells me the day of the week the person arrived.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data want;&lt;BR /&gt; set have ;&lt;BR /&gt;informat admitdatetime&amp;nbsp;DATETIME16.;&lt;BR /&gt;format &lt;SPAN&gt;admitdatetime&lt;/SPAN&gt; DATETIME16.;&lt;BR /&gt;date_arr= datepart(&lt;SPAN&gt;admitdatetime&lt;/SPAN&gt;);&lt;BR /&gt; time_arr=timepart(&lt;SPAN&gt;admitdatetime&lt;/SPAN&gt;);&lt;BR /&gt;day=weekday(date_arr);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I get missing values for&amp;nbsp;all of these new variables. The&amp;nbsp;&lt;SPAN&gt;admitdatetime is numeric, informat is DATETIME16. so the datepart/timepart function should work.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Sarah&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 May 2018 17:16:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datapart-and-Timepart-functions/m-p/460762#M117141</guid>
      <dc:creator>sarahsasuser</dc:creator>
      <dc:date>2018-05-08T17:16:22Z</dc:date>
    </item>
    <item>
      <title>Re: Datapart and Timepart functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datapart-and-Timepart-functions/m-p/460766#M117144</link>
      <description>&lt;P&gt;what's the need for informat statement when reading a datetime variable from a dataset that has datetime values?&lt;/P&gt;&lt;P&gt;Data want;&lt;BR /&gt;set have ;&lt;BR /&gt;format&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;admitdatetime&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;DATETIME20..;&lt;BR /&gt;date_arr= datepart(&lt;SPAN&gt;admitdatetime&lt;/SPAN&gt;);&lt;BR /&gt;time_arr=timepart(&lt;SPAN&gt;admitdatetime&lt;/SPAN&gt;);&lt;BR /&gt;day=weekday(date_arr);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 May 2018 17:26:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datapart-and-Timepart-functions/m-p/460766#M117144</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-08T17:26:35Z</dc:date>
    </item>
    <item>
      <title>Re: Datapart and Timepart functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datapart-and-Timepart-functions/m-p/460767#M117145</link>
      <description>&lt;P&gt;The informat was 16. and I added the datetime informat. I have tried running the code with only the format as you suggested below and it did not work. Neither did changing both informat and formats to the datetime20. Other ideas?&lt;/P&gt;</description>
      <pubDate>Tue, 08 May 2018 17:29:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datapart-and-Timepart-functions/m-p/460767#M117145</guid>
      <dc:creator>sarahsasuser</dc:creator>
      <dc:date>2018-05-08T17:29:58Z</dc:date>
    </item>
    <item>
      <title>Re: Datapart and Timepart functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datapart-and-Timepart-functions/m-p/460770#M117146</link>
      <description>&lt;P&gt;Can you paste a sample what your data looks like and a proc contents output?&lt;/P&gt;</description>
      <pubDate>Tue, 08 May 2018 17:30:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datapart-and-Timepart-functions/m-p/460770#M117146</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-08T17:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: Datapart and Timepart functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datapart-and-Timepart-functions/m-p/460775#M117148</link>
      <description>&lt;P&gt;Sure the contents are attached. The data are protected but the data look like this:&amp;nbsp;08MAY18:13:37:00&lt;/P&gt;
&lt;P&gt;This has been imported from an excel spreadsheet (xls).&lt;/P&gt;</description>
      <pubDate>Tue, 08 May 2018 17:37:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datapart-and-Timepart-functions/m-p/460775#M117148</guid>
      <dc:creator>sarahsasuser</dc:creator>
      <dc:date>2018-05-08T17:37:54Z</dc:date>
    </item>
    <item>
      <title>Re: Datapart and Timepart functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datapart-and-Timepart-functions/m-p/460777#M117149</link>
      <description>&lt;P&gt;strange as my test worked fine&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;log:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;354 data test;&lt;BR /&gt;355&lt;STRONG&gt; datetime='08MAY18:13:37:00'dt;&lt;/STRONG&gt;&lt;BR /&gt;356 date_arr= datepart(datetime);&lt;BR /&gt;357 time_arr=timepart(datetime);&lt;BR /&gt;358 day=weekday(date_arr);&lt;BR /&gt;359 put _all_;&lt;BR /&gt;360 format datetime datetime. date_arr date9. time_arr time5. ;&lt;BR /&gt;361 run;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;datetime=08MAY18:13:37:00 date_arr=08MAY2018 time_arr=13:37 day=3&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 May 2018 17:44:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datapart-and-Timepart-functions/m-p/460777#M117149</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-08T17:44:49Z</dc:date>
    </item>
    <item>
      <title>Re: Datapart and Timepart functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datapart-and-Timepart-functions/m-p/460779#M117150</link>
      <description>&lt;P&gt;OK, I played around with the excel file and figured out that it will work if I right justify the datetime column in excel. It doesn't appear differently in the imported SAS file (still left justified), but now the datepart and timepart work.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 May 2018 17:51:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datapart-and-Timepart-functions/m-p/460779#M117150</guid>
      <dc:creator>sarahsasuser</dc:creator>
      <dc:date>2018-05-08T17:51:39Z</dc:date>
    </item>
  </channel>
</rss>

