From: peter zeng on
I have two datetime values such as "13SEP99:19:45:04" and
"13SEP99:23:05:36"
I want (13SEP99:23:05:36)minus(13SEP99:19:45:04)
so that I can get the actural numebrs

Do everyone know how to do it

here is my code
format date date9. time time8. datetime datetime16.;
datetime=(date*24*60*60)+ time;

just learn SAS
From: Arthur Tabachneck on
Peter,

If you want the result shown in terms of hours you could just use:

data have;
start_time="13SEP99:19:45:04"dt;
end_time="13SEP99:23:05:36"dt;
run;

data want;
set have;
diff=(end_time-start_time)/(60*60);
run;

HTH,
Art
------------
On Oct 30, 4:37 pm, peter zeng <taifa.str...(a)gmail.com> wrote:
> I have two datetime values such as "13SEP99:19:45:04" and
> "13SEP99:23:05:36"
> I want (13SEP99:23:05:36)minus(13SEP99:19:45:04)
> so that I can get the actural numebrs
>
> Do everyone know how to do it
>
> here is my code
> format date date9. time time8. datetime datetime16.;
> datetime=(date*24*60*60)+ time;
>
> just learn SAS
From: Ruslan Kirhizau on
Hi=2C

=20

The answer depends on how your values are stored and/or read.=20

=20

If you have two SAS datetime values then you can just simply subtract one f=
rom another and get difference in seconds as a result. SAS datetime value i=
s numeric value representing number of seconds from midnight=2C January 1=
=2C 1960.=20

SAS date value is number of days from January=2C 1=2C 1960.=20

SAS time value is number of seconds from midnight. It resets to 0 every mid=
night.=20

All three counters (datetime=2C date and time) are numeric.

=20

If you have your values stored as character strings=2C then you need to con=
vert them to appropriate numeric date=2C time or datetime value first and p=
erform calculations after that.=20

You can use input finction=2C for example=2C if variables character_string1=
and character_string2 contain "13SEP99:19:45:04" and "13SEP99:23:05:36" :=
=20

num_dt1 =3D input (character_string1=2C datetime19.)=3B /*convert to the nu=
mber of seconds from midnight 1st Jan 1960*/ =
=20

num_dt2 =3D input (character_string2=2C datetime19.)=3B

dif =3D num_dt2 - num_dt1 =3B /*difference in seconds*/

format dif time5. =3B =20

=20

=20

SAS date/time formats have no effect on performed calculations. Formats cou=
ld be applied to the results for visual representation of the date or time.=
=20

=20

Hope this helps a little

=20

Thanks=20

=20

Ruslan

=20

=20

=20

=20

=20

=20




=20
> Date: Fri=2C 30 Oct 2009 13:37:11 -0700
> From: taifa.strong(a)GMAIL.COM
> Subject: sas time value
> To: SAS-L(a)LISTSERV.UGA.EDU
>=20
> I have two datetime values such as "13SEP99:19:45:04" and
> "13SEP99:23:05:36"
> I want (13SEP99:23:05:36)minus(13SEP99:19:45:04)
> so that I can get the actural numebrs
>=20
> Do everyone know how to do it
>=20
> here is my code
> format date date9. time time8. datetime datetime16.=3B
> datetime=3D(date*24*60*60)+ time=3B
>=20
> just learn SAS
=20
_________________________________________________________________
Windows 7: It works the way you want.
http://www.microsoft.com/Windows/windows-7/default.aspx?ocid=3DPID24727::T:=
WLMTAGL:ON:WL:en-US:WWL_WIN_evergreen2:112009=