Prev: online covariance-based SEM workshop using R statistical software
Next: update a column based on a column in another table
From: nick on 25 Feb 2010 06:14 hi, if i want to find the difference between two dates i can convert them to SAS dates using the YYMMDD8. format and then subtract one from the other. i'd like to find the time interval between two observations in minutes. my raw data is in the format DD/MM/YYYY HH:MM:SS, i.e. 25/01/10 07:11:25. is it possible to convert this with a format to a SAS time? thanks for your help, nick
From: Arthur Tabachneck on 25 Feb 2010 07:43 Nick, I think you can achieve what you want with something like: options datestyle=dmy; data have; informat dt1 dt2 anydtdtm17.; input dt1 dt2; minutes=timepart(dt2)-timepart(dt1); cards; 25/01/10:07:10:25 25/01/10:07:11:25 ; HTH, Art ---------- On Feb 25, 6:14 am, nick <nickcorbin0...(a)googlemail.com> wrote: > hi, if i want to find the difference between two dates i can convert > them to SAS dates using the YYMMDD8. format and then subtract one from > the other. > > i'd like to find the time interval between two observations in > minutes. my raw data is in the format DD/MM/YYYY HH:MM:SS, i.e. > 25/01/10 07:11:25. is it possible to convert this with a format to a > SAS time? > > thanks for your help, > > nick
From: Mark Miller on 25 Feb 2010 08:48 Just like for a pair of SAS <date> vars or SAS <time> vars, the difference between a pair of SAS <datetime> vars can be computed directly by subtraction i.e. <datetime1 - datetime2> The difference is in seconds. Divide by 60 to get minutes. .... Mark Miller On Thu, Feb 25, 2010 at 7:43 AM, Arthur Tabachneck <art297(a)netscape.net>wrote: > Nick, > > I think you can achieve what you want with something like: > > options datestyle=dmy; > data have; > informat dt1 dt2 anydtdtm17.; > input dt1 dt2; > minutes=timepart(dt2)-timepart(dt1); > cards; > 25/01/10:07:10:25 25/01/10:07:11:25 > ; > > HTH, > Art > ---------- > On Feb 25, 6:14 am, nick <nickcorbin0...(a)googlemail.com> wrote: > > hi, if i want to find the difference between two dates i can convert > > them to SAS dates using the YYMMDD8. format and then subtract one from > > the other. > > > > i'd like to find the time interval between two observations in > > minutes. my raw data is in the format DD/MM/YYYY HH:MM:SS, i.e. > > 25/01/10 07:11:25. is it possible to convert this with a format to a > > SAS time? > > > > thanks for your help, > > > > nick >
From: Arthur Tabachneck on 25 Feb 2010 09:52 Mark, Take a look at the example from my post earlier today. The result was 60 and no division was needed. options datestyle=dmy; data have; informat dt1 dt2 anydtdtm17.; input dt1 dt2; minutes=timepart(dt2)-timepart(dt1); cards; 25/01/10:07:10:25 25/01/10:07:11:25 ; Art ------ On Thu, 25 Feb 2010 08:48:07 -0500, Mark Miller <mdhmiller(a)GMAIL.COM> wrote: >Just like for a pair of SAS <date> vars or SAS <time> vars, >the difference between a pair of SAS <datetime> vars >can be computed directly by subtraction > i.e. <datetime1 - datetime2> >The difference is in seconds. >Divide by 60 to get minutes. > >... Mark Miller > >On Thu, Feb 25, 2010 at 7:43 AM, Arthur Tabachneck <art297(a)netscape.net>wrote: > >> Nick, >> >> I think you can achieve what you want with something like: >> >> options datestyle=dmy; >> data have; >> informat dt1 dt2 anydtdtm17.; >> input dt1 dt2; >> minutes=timepart(dt2)-timepart(dt1); >> cards; >> 25/01/10:07:10:25 25/01/10:07:11:25 >> ; >> >> HTH, >> Art >> ---------- >> On Feb 25, 6:14 am, nick <nickcorbin0...(a)googlemail.com> wrote: >> > hi, if i want to find the difference between two dates i can convert >> > them to SAS dates using the YYMMDD8. format and then subtract one from >> > the other. >> > >> > i'd like to find the time interval between two observations in >> > minutes. my raw data is in the format DD/MM/YYYY HH:MM:SS, i.e. >> > 25/01/10 07:11:25. is it possible to convert this with a format to a >> > SAS time? >> > >> > thanks for your help, >> > >> > nick >>
From: NordlDJ on 25 Feb 2010 11:41
Art, But that result was 60 seconds, not minutes, unless I am reading the time wrong. 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 > -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L(a)LISTSERV.UGA.EDU] On Behalf Of > Arthur Tabachneck > Sent: Thursday, February 25, 2010 6:52 AM > To: SAS-L(a)LISTSERV.UGA.EDU > Subject: Re: Converting a timestamp to a SAS time > > Mark, > > Take a look at the example from my post earlier today. The result was 60 > and no division was needed. > > options datestyle=dmy; > data have; > informat dt1 dt2 anydtdtm17.; > input dt1 dt2; > minutes=timepart(dt2)-timepart(dt1); > cards; > 25/01/10:07:10:25 25/01/10:07:11:25 > ; > > Art > ------ > On Thu, 25 Feb 2010 08:48:07 -0500, Mark Miller <mdhmiller(a)GMAIL.COM> > wrote: > > >Just like for a pair of SAS <date> vars or SAS <time> vars, > >the difference between a pair of SAS <datetime> vars > >can be computed directly by subtraction > > i.e. <datetime1 - datetime2> > >The difference is in seconds. > >Divide by 60 to get minutes. > > > >... Mark Miller > > > >On Thu, Feb 25, 2010 at 7:43 AM, Arthur Tabachneck > <art297(a)netscape.net>wrote: > > > >> Nick, > >> > >> I think you can achieve what you want with something like: > >> > >> options datestyle=dmy; > >> data have; > >> informat dt1 dt2 anydtdtm17.; > >> input dt1 dt2; > >> minutes=timepart(dt2)-timepart(dt1); > >> cards; > >> 25/01/10:07:10:25 25/01/10:07:11:25 > >> ; > >> > >> HTH, > >> Art > >> ---------- > >> On Feb 25, 6:14 am, nick <nickcorbin0...(a)googlemail.com> wrote: > >> > hi, if i want to find the difference between two dates i can convert > >> > them to SAS dates using the YYMMDD8. format and then subtract one from > >> > the other. > >> > > >> > i'd like to find the time interval between two observations in > >> > minutes. my raw data is in the format DD/MM/YYYY HH:MM:SS, i.e. > >> > 25/01/10 07:11:25. is it possible to convert this with a format to a > >> > SAS time? > >> > > >> > thanks for your help, > >> > > >> > nick > >> |