LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (October 2009, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 7 Oct 2009 14:46:12 -0700
Reply-To:     "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Subject:      Re: Date time conversion
In-Reply-To:  <200910072100.n97JWMQA007734@malibu.cc.uga.edu>
Content-Type: text/plain; charset=windows-1252

> -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Sid > N > Sent: Wednesday, October 07, 2009 2:00 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Date time conversion > > Hi, > > I have my date/time values in the following character format. Can someone > help me with converting them into mm/dd/yyyy hh:mm values. The date values > in the below sample can be read as mm/dd hh:mm. > > data have; > input date $ 11.; > cards; > 6/12 23:15 > 11/9 5:16 > 11/22 3:03 > 6/8 10:34 > 6/18 20:03 > 6/9 14:27 > 12/9 18:48 > 6/9 22:43 > 6/10 8:17 > 7/11 21:18 > 6/11 16:45 > ; > run; > > The output I am looking for is: > 06/12/2009 23:15 > 11/09/2009 05:16 > 11/22/2009 03:03 > ... and so on. Year can be assumed as 2009 for all observations. > > Thank you, > Sid

Sid,

You have received a couple of solutions. Here is one more with a picture format to give you the output that you wanted.

proc format; picture dtmdyhm '01jan1582:00:00:00'dt - '31dec2600:00:00:00'dt = '%0m/%0d/%Y %0H:%0M' (datatype=datetime) other = 'out of range' ; run;

data have; input date $ 11.; format datetime dtmdyhm.; datetime = input(cats(scan(date,1,' '),'/2009:',scan(date,2,' ')), anydtdtm.); cards; 6/12 23:15 11/9 5:16 11/22 3:03 6/8 10:34 6/18 20:03 6/9 14:27 12/9 18:48 6/9 22:43 6/10 8:17 7/11 21:18 6/11 16:45 ; run;

Hope this is helpful,

Dan

Daniel J. Nordlund Washington State Department of Social and Health Services Planning, Performance, and Accountability Research and Data Analysis Division Olympia, WA 98504-5204


Back to: Top of message | Previous page | Main SAS-L page