COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Re: Concatenating Times

• Follow

```Points to consider

Time8 format actually allows  a decimal portion for fractions of a
second  as in Time13.4

Milliseconds are 1000th of second so if your second variable is
milliseconds
the corresponding display would be  00:45:28.0073

If the milliseconds field is always the fractional part ( always <=3D
0999)
then you can probably use the SECOND function to extract the seconds
reconstruct
the complete time using the HMS function as in

TimeAll  =3D HMS( Hour(myTime), Minute(myTime), (Second(myTime) +
mSec/1000 )    ) ;

.... Mark Miller

On Thu, Jan 21, 2010 at 5:58 PM, Craig Johnson <cjohns38@gmail.com> wrote:

> This is probably easy I=92m just not sure how to do it.  I need a way to
> concatenate two numeric time fields that are storing times.  The first
> variable stores the start time of an event in the HH:MM:SS format
> (Time8.)  Naturally,
> the program we export from stores the milliseconds in a second variable i=
n
> best 12 format.  To do any analyses we need them together.   So, I need a
> way tack on the MS to the first variable so I end up with something like
> 00:45:28:73 rather than 00:45:28 and 73.
>
>
>
> Thoughts?
>
```
 0

```Time is already in seconds so just add the milliseconds as fractional
time.

22   data _null_;
23     t=3D'00:45:28't ;
24     ms=3D73;
25     t2=3Dt + ms/1000;
26     format t t2 time12.3;
27     put (t ms t2) (=3D/);
28   run;

t=3D0:45:28.000
ms=3D73
t2=3D0:45:28.073

On Jan 21, 6:32=A0pm, mdhmil...@GMAIL.COM (Mark Miller) wrote:
> Points to consider
>
> =A0 =A0 =A0Time8 format actually allows =A0a decimal portion for fraction=
s of a
> second =A0as in Time13.4
>
> =A0 =A0 =A0Milliseconds are 1000th of second so if your second variable i=
s
> milliseconds
> =A0 =A0 =A0the corresponding display would be =A000:45:28.0073
>
> =A0 =A0 =A0 If the milliseconds field is always the fractional part ( alw=
ays <=3D3D
> 0999)
> =A0 =A0 =A0 then you can probably use the SECOND function to extract the =
seconds
> =A0 =A0 =A0 from your Time variable then Add the milliseconds, and finall=
y
> reconstruct
> =A0 =A0 =A0 the complete time using the HMS function as in
>
> =A0 =A0 =A0TimeAll =A0=3D3D HMS( Hour(myTime), Minute(myTime), (Second(my=
Time) +
> mSec/1000 ) =A0 =A0) ;
>
> ... Mark Miller
>
>
>
>
>
> On Thu, Jan 21, 2010 at 5:58 PM, Craig Johnson <cjohn...@gmail.com> wrote=
:
> > This is probably easy I=3D92m just not sure how to do it. =A0I need a w=
ay to
> > concatenate two numeric time fields that are storing times. =A0The firs=
t
> > variable stores the start time of an event in the HH:MM:SS format
> > (Time8.) =A0Naturally,
> > the program we export from stores the milliseconds in a second variable=
i=3D
> n
> > best 12 format. =A0To do any analyses we need them together. =A0 So, I =
need a
> > way tack on the MS to the first variable so I end up with something lik=
e
> > 00:45:28:73 rather than 00:45:28 and 73.
>
> > Thoughts?- Hide quoted text -
>
> - Show quoted text -

```
 0

1 Replies
244 Views

Similiar Articles:

7/24/2012 9:02:21 AM