<?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: Date and Time Stamps in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Date-and-Time-Stamps/m-p/68586#M19664</link>
    <description>Declaring an INFORMAT statement does not automatically performing any interpretation or data-conversion. The issue is that when you declare your SET statement, then you have associated the DATE variable as a CHARACTER type SAS variable/column.&lt;BR /&gt;
&lt;BR /&gt;
If the data-string is character, then you must use the INPUT function in a SAS (new) variable assignment statement to convert using the appropriate INFORMAT.  The same would need to occur with DATE2, regarding the INPUT function.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
Suggested Google advanced search arguments, this topic / post:&lt;BR /&gt;
&lt;BR /&gt;
convert character date site:sas.com&lt;BR /&gt;
&lt;BR /&gt;
input function convert date variable site:sas.com</description>
    <pubDate>Tue, 24 May 2011 15:53:40 GMT</pubDate>
    <dc:creator>sbb</dc:creator>
    <dc:date>2011-05-24T15:53:40Z</dc:date>
    <item>
      <title>Date and Time Stamps</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-and-Time-Stamps/m-p/68580#M19658</link>
      <description>I'm trying to develop a column in my SAS dataset that combines both date and time into one column (Time1):&lt;BR /&gt;
&lt;BR /&gt;
     Date                          Time                         Time1&lt;BR /&gt;
11/22/2008                 0:08:26                      xxxxxxxxx&lt;BR /&gt;
11/22/2008                 0:16:26                      xxxxxxxxx &lt;BR /&gt;
11/22/2008                 0:24:26                      xxxxxxxxx&lt;BR /&gt;
&lt;BR /&gt;
so I can run an analysis accounting for temporal autocorrelation in my dataset. I saw a SAS article on combining date and time data together to give me the following format (ex. 1482223680). This is exactly what I need  but I was unable to clearly follow how to derive this in my extensively large dataset (&amp;gt;=100,000 lines of data). Supposedly, the date represents days since 1/1/1960 and time represent seconds since midnight or midnight of 1/1/1960 if specifying a datetime variable. Does anyone know of an easy coding to create this date/time stamp based on two seperate columns (i.e., Date and time)? Thank you very much!</description>
      <pubDate>Mon, 23 May 2011 19:09:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-and-Time-Stamps/m-p/68580#M19658</guid>
      <dc:creator>Buck1480</dc:creator>
      <dc:date>2011-05-23T19:09:42Z</dc:date>
    </item>
    <item>
      <title>Re: Date and Time Stamps</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-and-Time-Stamps/m-p/68581#M19659</link>
      <description>&lt;A href="http://support.sas.com/forums/message.jspa?messageID=55818" target="_blank"&gt;http://support.sas.com/forums/message.jspa?messageID=55818&lt;/A&gt;</description>
      <pubDate>Mon, 23 May 2011 19:54:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-and-Time-Stamps/m-p/68581#M19659</guid>
      <dc:creator>AndyJ</dc:creator>
      <dc:date>2011-05-23T19:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: Date and Time Stamps</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-and-Time-Stamps/m-p/68582#M19660</link>
      <description>Use the dhms function.  See, e.g., &lt;BR /&gt;
&lt;A href="http://www.hollandnumerics.co.uk/sasfaq/SASFAQ1.HTM" target="_blank"&gt;http://www.hollandnumerics.co.uk/sasfaq/SASFAQ1.HTM&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
HTH,&lt;BR /&gt;
Art&lt;BR /&gt;
----------&lt;BR /&gt;
&amp;gt; I'm trying to develop a column in my SAS dataset that&lt;BR /&gt;
&amp;gt; combines both date and time into one column (Time1):&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; Date                          Time&lt;BR /&gt;
&amp;gt;                         Time1&lt;BR /&gt;
&amp;gt;    0:08:26                      xxxxxxxxx&lt;BR /&gt;
&amp;gt; 22/2008                 0:16:26&lt;BR /&gt;
&amp;gt;                      xxxxxxxxx &lt;BR /&gt;
&amp;gt;       0:24:26                      xxxxxxxxx&lt;BR /&gt;
&amp;gt; can run an analysis accounting for temporal&lt;BR /&gt;
&amp;gt; autocorrelation in my dataset. I saw a SAS article&lt;BR /&gt;
&amp;gt; on combining date and time data together to give me&lt;BR /&gt;
&amp;gt; the following format (ex. 1482223680). This is&lt;BR /&gt;
&amp;gt; exactly what I need  but I was unable to clearly&lt;BR /&gt;
&amp;gt; follow how to derive this in my extensively large&lt;BR /&gt;
&amp;gt; dataset (&amp;gt;=100,000 lines of data). Supposedly, the&lt;BR /&gt;
&amp;gt; date represents days since 1/1/1960 and time&lt;BR /&gt;
&amp;gt; represent seconds since midnight or midnight of&lt;BR /&gt;
&amp;gt; 1/1/1960 if specifying a datetime variable. Does&lt;BR /&gt;
&amp;gt; anyone know of an easy coding to create this&lt;BR /&gt;
&amp;gt; date/time stamp based on two seperate columns (i.e.,&lt;BR /&gt;
&amp;gt;  Date and time)? Thank you very much!</description>
      <pubDate>Mon, 23 May 2011 19:56:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-and-Time-Stamps/m-p/68582#M19660</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-05-23T19:56:23Z</dc:date>
    </item>
    <item>
      <title>Re: Date and Time Stamps</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-and-Time-Stamps/m-p/68583#M19661</link>
      <description>Ok! I've read over the comments you posted below and still am a little confused. See my SAS code below:&lt;BR /&gt;
&lt;BR /&gt;
DATA DATETIME;&lt;BR /&gt;
SET DEER1;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
DATA CORRECT;&lt;BR /&gt;
SET DATETIME; &lt;BR /&gt;
INFORMAT DATE MMDDYY10.;&lt;BR /&gt;
DATE2=DATE;&lt;BR /&gt;
FORMAT DATE2 MMDDYY10.;&lt;BR /&gt;
HRID=HMS(HOUR,MINUTE,SECOND); &lt;BR /&gt;
H_M_S=HRID;&lt;BR /&gt;
FORMAT H_M_S TIME.;&lt;BR /&gt;
DTID=DHMS(DATE2,HOUR,MINUTE,SECOND);&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
PROC PRINT; RUN;&lt;BR /&gt;
&lt;BR /&gt;
DATA HABITAT; SET CORRECT; RUN;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Do you see any inherent problems? I'm importing the data from an Excel file because I have approximately 100,000 lines of data and figured it would be easier to make sure things don't get jumbled up in the process of using DATALINES. I ran the code last night and kept getting the following errors: &lt;BR /&gt;
&lt;BR /&gt;
46573 DATA DATETIME;&lt;BR /&gt;
46574 SET DEER1;&lt;BR /&gt;
46575 RUN;&lt;BR /&gt;
NOTE: There were 46492 observations read from the data set WORK.DEER1.&lt;BR /&gt;
NOTE: The data set WORK.DATETIME has 46492 observations and 37 variables.&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
real time 0.10 seconds&lt;BR /&gt;
cpu time 0.09 seconds&lt;BR /&gt;
　&lt;BR /&gt;
46576 DATA CORRECT;&lt;BR /&gt;
46577 SET DATETIME;&lt;BR /&gt;
46578 INFORMAT DATE MMDDYY10.;&lt;BR /&gt;
---------&lt;BR /&gt;
48&lt;BR /&gt;
ERROR 48-59: The informat $MMDDYY was not found or could not be loaded.&lt;BR /&gt;
46579 DATE2=DATE;&lt;BR /&gt;
46580 FORMAT DATE2 MMDDYY10.;&lt;BR /&gt;
---------&lt;BR /&gt;
48&lt;BR /&gt;
ERROR 48-59: The format $MMDDYY was not found or could not be loaded. &lt;BR /&gt;
46581 HRID=HMS(HOUR,MINUTE,SECOND);&lt;BR /&gt;
46582 H_M_S=HRID;&lt;BR /&gt;
46583 FORMAT H_M_S TIME.;&lt;BR /&gt;
46584 DTID=DHMS(DATE2,HOUR,MINUTE,SECOND);&lt;BR /&gt;
46585 RUN;&lt;BR /&gt;
NOTE: Character values have been converted to numeric values at the places given by:&lt;BR /&gt;
(Line):(Column).&lt;BR /&gt;
46584:11&lt;BR /&gt;
NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;
WARNING: The data set WORK.CORRECT may be incomplete. When this step was stopped there were 0&lt;BR /&gt;
observations and 41 variables.&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
real time 0.03 seconds&lt;BR /&gt;
cpu time 0.06 seconds&lt;BR /&gt;
　&lt;BR /&gt;
46586 PROC PRINT; RUN;&lt;BR /&gt;
NOTE: No observations in data set WORK.CORRECT.&lt;BR /&gt;
NOTE: PROCEDURE PRINT used (Total process time):&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thank you very much for any help that you can give me!</description>
      <pubDate>Tue, 24 May 2011 14:43:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-and-Time-Stamps/m-p/68583#M19661</guid>
      <dc:creator>Buck1480</dc:creator>
      <dc:date>2011-05-24T14:43:22Z</dc:date>
    </item>
    <item>
      <title>Re: Date and Time Stamps</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-and-Time-Stamps/m-p/68584#M19662</link>
      <description>When SAS adds a "$" that means that the SAS variable type is CHARACTER, not the required numeric -- honestly, it's a lame diagnostic indication but hey it's SAS and the SAS environment has been generating such goofy warnings/errors since SAS 79 era.&lt;BR /&gt;
&lt;BR /&gt;
So, when you are using a SAS NUMERIC type variable, the associated FORMAT/INFORMAT also must be for the same variable type.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Tue, 24 May 2011 14:49:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-and-Time-Stamps/m-p/68584#M19662</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-05-24T14:49:49Z</dc:date>
    </item>
    <item>
      <title>Re: Date and Time Stamps</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-and-Time-Stamps/m-p/68585#M19663</link>
      <description>So are you saying that I can't create the DATE2 column? The INFORMAT date and time are in the following format: Date = 11/22/2008 and Time = 09:22:26. My goal is to create a time stamp joining both date and time. I see your point about FORMAT and INFORMAT must be the same variable type but doesn't the code reflect that? Sorry for the confusion! Thank you very much for your help!</description>
      <pubDate>Tue, 24 May 2011 15:13:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-and-Time-Stamps/m-p/68585#M19663</guid>
      <dc:creator>Buck1480</dc:creator>
      <dc:date>2011-05-24T15:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: Date and Time Stamps</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-and-Time-Stamps/m-p/68586#M19664</link>
      <description>Declaring an INFORMAT statement does not automatically performing any interpretation or data-conversion. The issue is that when you declare your SET statement, then you have associated the DATE variable as a CHARACTER type SAS variable/column.&lt;BR /&gt;
&lt;BR /&gt;
If the data-string is character, then you must use the INPUT function in a SAS (new) variable assignment statement to convert using the appropriate INFORMAT.  The same would need to occur with DATE2, regarding the INPUT function.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
Suggested Google advanced search arguments, this topic / post:&lt;BR /&gt;
&lt;BR /&gt;
convert character date site:sas.com&lt;BR /&gt;
&lt;BR /&gt;
input function convert date variable site:sas.com</description>
      <pubDate>Tue, 24 May 2011 15:53:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-and-Time-Stamps/m-p/68586#M19664</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-05-24T15:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: Date and Time Stamps</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-and-Time-Stamps/m-p/68587#M19665</link>
      <description>assuming these are string columns of date and time, you can make one timestamp with the code using the INPUT() function with the informat MDYAMPM.&lt;BR /&gt;
  [pre]timestamp = input( date !!'-'!! time, mdyampm. ) ;</description>
      <pubDate>Tue, 24 May 2011 20:41:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-and-Time-Stamps/m-p/68587#M19665</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-05-24T20:41:57Z</dc:date>
    </item>
  </channel>
</rss>

