From: "Data _null_;" on 18 Dec 2009 08:14 I don't follow. What is "proper time"? Do you have example? On 12/18/09, goladin(a)gmail.com <goladin(a)gmail.com> wrote: > Hi, > > Wouldn't we use a kind of modulus function to extract the proper time? > > > On Dec 18, 2009 8:31pm, "Data _null_;" <iebupdte(a)gmail.com> wrote: > > Suppose the time was a duration. Would we create a datetime value as > > > > the OP wants? If we would then the way the DHMS function is called > > > > will yield different results. For example... > > > > > > > > 3077 data _null_; > > > > 3078 date = today(); > > > > 3079 time = '25:30:30't; > > > > 3080 put time=time8.; > > > > 3081 h = hour(time); > > > > 3082 m = minute(time); > > > > 3083 s = second(time); > > > > 3084 put (h m s)(=); > > > > 3085 dt1 = dhms(date,h,m,s); > > > > 3086 dt2 = dhms(date,0,0,time); > > > > 3087 put (dt1 dt2) (=datetime.); > > > > 3088 run; > > > > > > > > time=25:30:30 > > > > h=1 m=30 s=30 > > > > dt1=18DEC09:01:30:30 dt2=19DEC09:01:30:30 > > > > > > > > > > > > Does creating a datetime from a date and a duration make sense? > > > > > > > > > > > > > > > > On 12/18/09, Murphy Choy goladin(a)gmail.com> wrote: > > > > > Hi, > > > > > > > > > > You can use dhms with hour, minute and second functions. > > > > > > > > > > ------Original Message------ > > > > > From: Annie Lee > > > > > Sender: SAS(r) Discussion > > > > > To: SAS-L(a)LISTSERV.UGA.EDU > > > > > ReplyTo: Annie Lee > > > > > Subject: how to combine date and time to make it datetime > > > > > Sent: Dec 18, 2009 2:56 PM > > > > > > > > > > Hi, > > > > > > > > > > I would like to combine mydate and mytime to create mydatetime. > > > > > I would appreciate it if anyone would offer some help. > > > > > > > > > > > > > > > > > > > > *** In excel: > > > > > mydate mytime > > > > > 1/2/2009 12:00:00 AM 7:45:00 AM > > > > > > > > > > > > > > > *** After reading the data into SAS > > > > > mydate: Number 8 date9. > > > > > mytime: Number 8 time8. > > > > > > > > > > > > > > > mydate mytime > > > > > 02JAN2009 7:45:00 > > > > > > > > > > > > > > > > > > > > *** Results I would like: > > > > > I would like to combine mydate and mytime to create mydatetime. > > > > > > > > > > mydate mytime mydatetime > > > > > 02JAN2009 7:45:00 02JAN2009:07:45:00 > > > > > > > > > > > > > > > > > > > > *** codes I tried and the (wrong) result I got. > > > > > > > > > > mydate mytime mydatetime > > > > > 02JAN2009 7:45:00 01JAN60:07:45:00 > > > > > > > > > > > > > > > > > > > > > > > > > Options validVarName=any ; > > > > > > > > > > PROC IMPORT OUT= WORK.one > > > > > DATAFILE= "c:\Service" > > > > > DBMS=EXCEL REPLACE; > > > > > SHEET="Service$"; > > > > > GETNAMES=YES; > > > > > MIXED=NO; > > > > > SCANTEXT=YES; > > > > > USEDATE=YES; > > > > > SCANTIME=YES; > > > > > RUN; > > > > > > > > > > > > > > > data two; > > > > > set one; > > > > > myDateTime = datepart(mydate) + mytime; > > > > > run; > > > > > > > > > > > > > > > Sent from my BlackBerry Wireless Handheld > > > > > > > > > > -- > > > > > Regards, > > > > > Murphy Choy > > > > > > > > > > Certified Advanced Programmer for SAS V9 > > > > > Certified Basic Programmer for SAS V9 > > > > > > >
From: Lou on 18 Dec 2009 10:32 SAS date values are integers - the number of days since 01-January-1960. All days are 86,400 seconds long. SAS time values are also integers - the number of seconds since midnight. SAS date-time values are the number of seconds since midnight, 01-January-1960. Depending on the release of SAS you're using, you may be able to use the DHMS function, but if that's not available to you, the following formula will convert date and time values to date-time values: SAS-date-time-value = (SAS-date-value * 86,400) + SAS-time-value "Annie Lee" <hummingbird10111(a)HOTMAIL.COM> wrote in message news:200912180656.nBHJ1Ti0009874(a)malibu.cc.uga.edu... > Hi, > > I would like to combine mydate and mytime to create mydatetime. > I would appreciate it if anyone would offer some help. > > > > *** In excel: > mydate mytime > 1/2/2009 12:00:00 AM 7:45:00 AM > > > *** After reading the data into SAS > mydate: Number 8 date9. > mytime: Number 8 time8. > > > mydate mytime > 02JAN2009 7:45:00 > > > > *** Results I would like: > I would like to combine mydate and mytime to create mydatetime. > > mydate mytime mydatetime > 02JAN2009 7:45:00 02JAN2009:07:45:00 > > > > *** codes I tried and the (wrong) result I got. > > mydate mytime mydatetime > 02JAN2009 7:45:00 01JAN60:07:45:00 > > > > > Options validVarName=any ; > > PROC IMPORT OUT= WORK.one > DATAFILE= "c:\Service" > DBMS=EXCEL REPLACE; > SHEET="Service$"; > GETNAMES=YES; > MIXED=NO; > SCANTEXT=YES; > USEDATE=YES; > SCANTIME=YES; > RUN; > > > data two; > set one; > myDateTime = datepart(mydate) + mytime; > run;
From: Gerhard Hellriegel on 18 Dec 2009 11:52
the DHMS function is available for sure! I'm not sure about V5, but in V6 and higher it is! use it like: dtm = dhms(mydate,0,0,mytime); you can also extract the hour, minute and second with the functions of exactly that names, but that's not necessary. Don't forget to format format dtm datetime20.; to make it more readayble. Gerhard On Fri, 18 Dec 2009 10:32:57 -0500, Lou <lpogoda(a)HOTMAIL.COM> wrote: >SAS date values are integers - the number of days since 01-January-1960. >All days are 86,400 seconds long. SAS time values are also integers - the >number of seconds since midnight. SAS date-time values are the number of >seconds since midnight, 01-January-1960. > >Depending on the release of SAS you're using, you may be able to use the >DHMS function, but if that's not available to you, the following formula >will convert date and time values to date-time values: > >SAS-date-time-value = (SAS-date-value * 86,400) + SAS-time-value > >"Annie Lee" <hummingbird10111(a)HOTMAIL.COM> wrote in message >news:200912180656.nBHJ1Ti0009874(a)malibu.cc.uga.edu... >> Hi, >> >> I would like to combine mydate and mytime to create mydatetime. >> I would appreciate it if anyone would offer some help. >> >> >> >> *** In excel: >> mydate mytime >> 1/2/2009 12:00:00 AM 7:45:00 AM >> >> >> *** After reading the data into SAS >> mydate: Number 8 date9. >> mytime: Number 8 time8. >> >> >> mydate mytime >> 02JAN2009 7:45:00 >> >> >> >> *** Results I would like: >> I would like to combine mydate and mytime to create mydatetime. >> >> mydate mytime mydatetime >> 02JAN2009 7:45:00 02JAN2009:07:45:00 >> >> >> >> *** codes I tried and the (wrong) result I got. >> >> mydate mytime mydatetime >> 02JAN2009 7:45:00 01JAN60:07:45:00 >> >> >> >> >> Options validVarName=any ; >> >> PROC IMPORT OUT= WORK.one >> DATAFILE= "c:\Service" >> DBMS=EXCEL REPLACE; >> SHEET="Service$"; >> GETNAMES=YES; >> MIXED=NO; >> SCANTEXT=YES; >> USEDATE=YES; >> SCANTIME=YES; >> RUN; >> >> >> data two; >> set one; >> myDateTime = datepart(mydate) + mytime; >> run; |