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 (December 2006, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 19 Dec 2006 05:22:56 -0500
Reply-To:     Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Subject:      Re: how to read datetime value from raw file?... Help plz

Your output looks like you want both, date and datetime values in one variable. That is impossible! It is only possible to store datetime values where you have time AND date - information in ONE variable. One possibility to do that in all SAS versions:

data need; input line $80.; dc=scan(line,1," "); tc=scan(line,2," "); pm=scan(line,3," "); date=input(dc,mmddyy10.); time=0; if tc ne " " then do; time=input(tc,time8.); add=0; if upcase(pm)=:"P" then add="12:00:00"t; time+add; end; datetime=dhms(date,hour(time),minute(time),second(time)); format datetime datetime20.; cards; 8/14/01 8:40:00 AM 9/23/01 4:27:00 PM 8/28/01 8/14/01 10:22:00 AM 2/21/02 9:50:00 AM 11/14/01 12/21/02 9:50:00 AM ; run;

That assumes that time is 0 if you have none. Regards, Gerhard

On Tue, 19 Dec 2006 09:12:23 +0000, Alex S <alex4sas@YAHOO.CO.IN> wrote:

>Dear All, > i need to read a datetime values from the rawfiles. For some observation i will have datetime values, some observation i will have only date values. > i need to have both date and time in one variable not in two variable. > > --------------------------------- > data need; > input datetime datetime18.; > cards; > 8/14/01 8:40:00 AM > 9/23/01 4:27:00 PM > 8/28/01 > 8/14/01 10:22:00 AM > 2/21/02 9:50:00 AM > 11/14/01 > 12/21/02 9:50:00 AM > ; > --------------------------------- > OutPut should be: > Datetime > 8/14/01 8:40:00 > 9/23/01 4:27:00 > 8/28/01 > 8/14/01 10:22:00 > 2/21/02 9:50:00 > 11/14/01 > 12/21/02 9:50:00 > --------------------------------- > Any help would be greatly appreciated. > > Thanks you in Advance, > Regards, > Alex S > > > Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download Now! http://messenger.yahoo.com/download.php


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