<?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 codes not working to extract separate columns of dates and time from one column. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/codes-not-working-to-extract-separate-columns-of-dates-and-time/m-p/891898#M352310</link>
    <description>&lt;P&gt;&amp;nbsp;I have a big data set consists of two columns, its sample is following:&lt;/P&gt;&lt;P&gt;timestamp&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;users&lt;/P&gt;&lt;P&gt;2/05/2018 4:53&amp;nbsp; &amp;nbsp; &amp;nbsp; 150785&lt;/P&gt;&lt;P&gt;2/05/2018 6:38&amp;nbsp; &amp;nbsp; &amp;nbsp; 150785&lt;/P&gt;&lt;P&gt;3/05/2018 0:35&amp;nbsp; &amp;nbsp; &amp;nbsp; 145510&lt;/P&gt;&lt;P&gt;3/05/2018 13:43&amp;nbsp; &amp;nbsp; &amp;nbsp; 145511&lt;/P&gt;&lt;P&gt;Now I nee two separate columns of date and time. For that purpose I am using following code:&lt;/P&gt;&lt;P&gt;data amz_processed;&lt;BR /&gt;set amz;&lt;BR /&gt;date = datepart(timestamp);&lt;BR /&gt;time = timepart(timestamp);&lt;/P&gt;&lt;P&gt;format date yymmdd10. time timeampm.;&lt;/P&gt;&lt;P&gt;drop timestamp;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;but in output file datepart and timepart columns are empty with log error in log file: Invalid numeric data. Please correct me where I am doing wrong.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Thu, 31 Aug 2023 11:07:07 GMT</pubDate>
    <dc:creator>Fatima123456</dc:creator>
    <dc:date>2023-08-31T11:07:07Z</dc:date>
    <item>
      <title>codes not working to extract separate columns of dates and time from one column.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/codes-not-working-to-extract-separate-columns-of-dates-and-time/m-p/891898#M352310</link>
      <description>&lt;P&gt;&amp;nbsp;I have a big data set consists of two columns, its sample is following:&lt;/P&gt;&lt;P&gt;timestamp&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;users&lt;/P&gt;&lt;P&gt;2/05/2018 4:53&amp;nbsp; &amp;nbsp; &amp;nbsp; 150785&lt;/P&gt;&lt;P&gt;2/05/2018 6:38&amp;nbsp; &amp;nbsp; &amp;nbsp; 150785&lt;/P&gt;&lt;P&gt;3/05/2018 0:35&amp;nbsp; &amp;nbsp; &amp;nbsp; 145510&lt;/P&gt;&lt;P&gt;3/05/2018 13:43&amp;nbsp; &amp;nbsp; &amp;nbsp; 145511&lt;/P&gt;&lt;P&gt;Now I nee two separate columns of date and time. For that purpose I am using following code:&lt;/P&gt;&lt;P&gt;data amz_processed;&lt;BR /&gt;set amz;&lt;BR /&gt;date = datepart(timestamp);&lt;BR /&gt;time = timepart(timestamp);&lt;/P&gt;&lt;P&gt;format date yymmdd10. time timeampm.;&lt;/P&gt;&lt;P&gt;drop timestamp;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;but in output file datepart and timepart columns are empty with log error in log file: Invalid numeric data. Please correct me where I am doing wrong.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2023 11:07:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/codes-not-working-to-extract-separate-columns-of-dates-and-time/m-p/891898#M352310</guid>
      <dc:creator>Fatima123456</dc:creator>
      <dc:date>2023-08-31T11:07:07Z</dc:date>
    </item>
    <item>
      <title>Re: codes not working to extract separate columns of dates and time from one column.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/codes-not-working-to-extract-separate-columns-of-dates-and-time/m-p/891901#M352312</link>
      <description>&lt;P&gt;Is your timestamp variable numeric and contains a SAS Datetime value?&lt;/P&gt;
&lt;P&gt;Please run below code and let us know.&lt;/P&gt;
&lt;PRE&gt;proc contents data=&amp;lt;libref&amp;gt;.&amp;lt;table&amp;gt;(keep=timestamp);
run;

proc print data=&amp;lt;libref&amp;gt;.&amp;lt;table&amp;gt;(keep=timestamp obs=1);
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2023 11:18:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/codes-not-working-to-extract-separate-columns-of-dates-and-time/m-p/891901#M352312</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-08-31T11:18:43Z</dc:date>
    </item>
    <item>
      <title>Re: codes not working to extract separate columns of dates and time from one column.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/codes-not-working-to-extract-separate-columns-of-dates-and-time/m-p/891968#M352344</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/446759"&gt;@Fatima123456&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but in output file datepart and timepart columns are empty with &lt;STRONG&gt;log error in log file: Invalid numeric data.&lt;/STRONG&gt; Please correct me where I am doing wrong.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;ANY &lt;/STRONG&gt;time you have an error and want help addressing it then provide the log for the step that creates the error. Copy the text of the &lt;STRONG&gt;code&lt;/STRONG&gt; and &lt;STRONG&gt;all notes, warnings and error messages&lt;/STRONG&gt;. On the forum open a text box using the &amp;lt;/&amp;gt; icon above the message window. Paste the text into the box.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The text box is important because it will preserve formatting of text including the diagnostic information SAS often provides that will be stripped out when pasted in to the main message window. The box also serves to separate the code and messages more clearly from discussion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your particular error means that I would place a fair sized wager that your "timestamp" is a character variable and not a SAS datetime value that the DATEPART and TIMEPART functions require.&lt;/P&gt;
&lt;P&gt;A second strong clue is the values you show for "timestamp" are not in any likely SAS format unless someone in your organization has spend some time creating a custom format that is not-well-though-out (in my opinion).&amp;nbsp; Why 2/ (one digit) and then 05/ (two digits) for example is pretty odd mixture.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2023 15:23:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/codes-not-working-to-extract-separate-columns-of-dates-and-time/m-p/891968#M352344</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-08-31T15:23:20Z</dc:date>
    </item>
  </channel>
</rss>

