<?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 &amp; Time Conversion in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Date-Time-Conversion/m-p/54990#M15281</link>
    <description>It looks like PROCESS_DT and PROCESS_TIME are character variables (given the leading zeros).  Do you want the result to be a SAS date/time variable or a character variable?</description>
    <pubDate>Thu, 21 Apr 2011 14:59:23 GMT</pubDate>
    <dc:creator>RickM</dc:creator>
    <dc:date>2011-04-21T14:59:23Z</dc:date>
    <item>
      <title>Date &amp; Time Conversion</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-Time-Conversion/m-p/54989#M15280</link>
      <description>Hi All, &lt;BR /&gt;
&lt;BR /&gt;
I have got a text file which has date &amp;amp; timing which relates to the process starting time and time it took for it to complete. Now I want to maintain all this timing in a table. But the problem that I am facing is with the date and time in a number format. For ex: &lt;BR /&gt;
1. Process_Dt has a value of 010911 which can be intrepreted as a Jan 9th, 2011. I want to convert this 010911 into 01/09/11 or 01/09/2011 format. I tried something like this: &lt;BR /&gt;
          date = PROCESS_DT;&lt;BR /&gt;
         PUT date = mmddyys10.;&lt;BR /&gt;
but it didn't work. Can someone provide me some guidance on how can I achieve this?&lt;BR /&gt;
&lt;BR /&gt;
2. Process_Time: So similar to date the timing in the txt file is like 1720 or 0820 which can be read as 17:20:00 PM or 08:20:00 AM. I am not able to figure how to convert this into time. I tried creating a providing a format of Time9. when I imported the file but all in vain. &lt;BR /&gt;
&lt;BR /&gt;
This is what I tried for time: &lt;BR /&gt;
FORMAT PROCESS_TIME TIME9.&lt;BR /&gt;
&lt;BR /&gt;
It gave me some value like 0:28:40 which obviously doesn't make sense. Can you please provide share your knowledge on how can I convert the time ?&lt;BR /&gt;
&lt;BR /&gt;
Thanks for your support.</description>
      <pubDate>Thu, 21 Apr 2011 14:50:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-Time-Conversion/m-p/54989#M15280</guid>
      <dc:creator>Pritish</dc:creator>
      <dc:date>2011-04-21T14:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: Date &amp; Time Conversion</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-Time-Conversion/m-p/54990#M15281</link>
      <description>It looks like PROCESS_DT and PROCESS_TIME are character variables (given the leading zeros).  Do you want the result to be a SAS date/time variable or a character variable?</description>
      <pubDate>Thu, 21 Apr 2011 14:59:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-Time-Conversion/m-p/54990#M15281</guid>
      <dc:creator>RickM</dc:creator>
      <dc:date>2011-04-21T14:59:23Z</dc:date>
    </item>
    <item>
      <title>Re: Date &amp; Time Conversion</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-Time-Conversion/m-p/54991#M15282</link>
      <description>Hey Rick:&lt;BR /&gt;
&lt;BR /&gt;
No they don't have a character variable. I gave the example which I think created the confusion. They are in numeric format. &lt;BR /&gt;
&lt;BR /&gt;
I want it to store Process_Dt in Date format and Process_Time in Time format in SAS.</description>
      <pubDate>Thu, 21 Apr 2011 15:17:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-Time-Conversion/m-p/54991#M15282</guid>
      <dc:creator>Pritish</dc:creator>
      <dc:date>2011-04-21T15:17:08Z</dc:date>
    </item>
    <item>
      <title>Re: Date &amp; Time Conversion</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-Time-Conversion/m-p/54992#M15283</link>
      <description>Would Process_Dt still have leading zeros for day of the month? For example Jan. 9th 2011 would be 10911 or would it be 1911?</description>
      <pubDate>Thu, 21 Apr 2011 15:22:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-Time-Conversion/m-p/54992#M15283</guid>
      <dc:creator>RickM</dc:creator>
      <dc:date>2011-04-21T15:22:44Z</dc:date>
    </item>
    <item>
      <title>Re: Date &amp; Time Conversion</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-Time-Conversion/m-p/54993#M15284</link>
      <description>Well, that's a good question Rick. &lt;BR /&gt;
&lt;BR /&gt;
I have both sort of values in my txt file. ex: 010911 and 100110&lt;BR /&gt;
&lt;BR /&gt;
The date in the txt file are 6 digits in length.</description>
      <pubDate>Thu, 21 Apr 2011 15:30:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-Time-Conversion/m-p/54993#M15284</guid>
      <dc:creator>Pritish</dc:creator>
      <dc:date>2011-04-21T15:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: Date &amp; Time Conversion</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-Time-Conversion/m-p/54994#M15285</link>
      <description>You could do something like month=floor(PROCESS_DT/10000), day=floor(PROCESS_DT/100)-month*100, etc. and then use date=MDY(month,day,year) to get a SAS date.  There is a similar function for time, HMS(Hours, Minutes, Seconds).&lt;BR /&gt;
&lt;BR /&gt;
Good luck!</description>
      <pubDate>Thu, 21 Apr 2011 15:47:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-Time-Conversion/m-p/54994#M15285</guid>
      <dc:creator>RickM</dc:creator>
      <dc:date>2011-04-21T15:47:30Z</dc:date>
    </item>
    <item>
      <title>Re: Date &amp; Time Conversion</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-Time-Conversion/m-p/54995#M15286</link>
      <description>Using a DATA step technique, take advantage of SAS INPUT function and use the appropriate INFORMAT to convert your numeric data-string (or otherwise a character data-string) into a SAS NUMERIC variable (DATE type) with the desired FORMAT applied for reporting.&lt;BR /&gt;
&lt;BR /&gt;
If you truly have a SAS numeric variable with mmddyy, then you will need to also use a PUT within the INPUT, such as:&lt;BR /&gt;
&lt;BR /&gt;
DATA _NULL_;&lt;BR /&gt;
FORMAT MYDATE YYMMDDS10.;&lt;BR /&gt;
MYDATE = INPUT(PUT(010111,Z6.),ANYDTDTE.);&lt;BR /&gt;
PUT MYDATE= ;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
And, for numeric TIME data-string conversion, do something similar again with INPUT and PUT, using the appropriate INFORMAT.&lt;BR /&gt;
&lt;BR /&gt;
Suggest you start by reviewing SAS support website technical documentatoin and supplemental reference materials on this topic -- see search argument below.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
Suggested Google advanced search argument, this topic / post:&lt;BR /&gt;
&lt;BR /&gt;
sas dates introduction site:sas.com</description>
      <pubDate>Thu, 21 Apr 2011 16:13:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-Time-Conversion/m-p/54995#M15286</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-04-21T16:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: Date &amp; Time Conversion</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-Time-Conversion/m-p/54996#M15287</link>
      <description>Hi Sbb, &lt;BR /&gt;
&lt;BR /&gt;
Thanks for your reply. It was really helpful. For the Process_Time I did something like this: &lt;BR /&gt;
&lt;BR /&gt;
DATA _NULL_;&lt;BR /&gt;
FORMAT MYTIME TIME9.;&lt;BR /&gt;
YY = PUT(00,Z2.);&lt;BR /&gt;
MYTIME = INPUT(PUT(0820,Z4.)||YY, ND8601TM10.);&lt;BR /&gt;
PUT MYTIME=;&lt;BR /&gt;
PUT _ALL_;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
The reason why I am concatenating 00 is b'coz i just have "1820" or "0820" in my text file. &lt;BR /&gt;
&lt;BR /&gt;
Do let me know if you have better way of doing it. &lt;BR /&gt;
&lt;BR /&gt;
Thanks again.&lt;BR /&gt;
&lt;BR /&gt;
@ Everyone: Thanks for checking out and helping me. Really appreciate your time.</description>
      <pubDate>Thu, 21 Apr 2011 18:25:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-Time-Conversion/m-p/54996#M15287</guid>
      <dc:creator>Pritish</dc:creator>
      <dc:date>2011-04-21T18:25:19Z</dc:date>
    </item>
    <item>
      <title>Re: Date &amp; Time Conversion</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-Time-Conversion/m-p/54997#M15288</link>
      <description>I am afraid you need to make a delimiter between hour and minute to let sas know it is time.&lt;BR /&gt;
[pre]&lt;BR /&gt;
data temp;&lt;BR /&gt;
 input date : mmddyy6. char_time : $6.;&lt;BR /&gt;
 time=input(catx(':',substr(char_time,1,2),substr(char_time,3,2)),time.) ;&lt;BR /&gt;
 format date mmddyy10. time timeampm.;&lt;BR /&gt;
 drop char_time;&lt;BR /&gt;
cards;&lt;BR /&gt;
010911 1720&lt;BR /&gt;
020310 0820&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Fri, 22 Apr 2011 05:16:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-Time-Conversion/m-p/54997#M15288</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-04-22T05:16:00Z</dc:date>
    </item>
  </channel>
</rss>

