## help

Solved
Occasional Contributor
Posts: 12

# help

i have the time data as follows;

Timestamp          Price

03:45:23:555       234

03:45:45:323       264

03:46:01:234       264

03:46:34:123       265

These are steps what i did and want to do with the data

-I have read the data in \$12. informat since i couldnt do it in numeric # if can be done in numeric, help me.

-then changed it into numeric format using input function.

-i want to get the minute only but not succeeded

I have to create a minute interval from it, use  in Do loops to get ther required data from within the interval of minute.

That would be a great HELP.

Thanks,

Accepted Solutions
Solution
‎06-14-2016 06:02 AM
Posts: 1,115

## Re: help

You can create SAS time values from your 12-character strings. These in turn can be truncated to minutes. The resulting time values (hh:mm) define groups of observations, for which you can derive the first, last, lowest, highest, average, ... price. If your dataset contains data from more than one date, you should also take care of the dates, though.

``````data want;
input ct :\$12. price;
t=input(compress(ct,':'), b8601tm9.); /* SAS time value */
ttm=hms(hour(t),minute(t),0); /* time truncated to minutes */
format t   e8601tm12.3
ttm tod5.;
cards;
03:45:23:555 234
03:45:45:323 264
03:46:01:234 264
03:46:34:123 265
;

proc print data=want;
run;``````

PS: In future posts I'm sure you'll be able to come up with a more informative title than "help".

All Replies
Solution
‎06-14-2016 06:02 AM
Posts: 1,115

## Re: help

You can create SAS time values from your 12-character strings. These in turn can be truncated to minutes. The resulting time values (hh:mm) define groups of observations, for which you can derive the first, last, lowest, highest, average, ... price. If your dataset contains data from more than one date, you should also take care of the dates, though.

``````data want;
input ct :\$12. price;
t=input(compress(ct,':'), b8601tm9.); /* SAS time value */
ttm=hms(hour(t),minute(t),0); /* time truncated to minutes */
format t   e8601tm12.3
ttm tod5.;
cards;
03:45:23:555 234
03:45:45:323 264
03:46:01:234 264
03:46:34:123 265
;

proc print data=want;
run;``````

PS: In future posts I'm sure you'll be able to come up with a more informative title than "help".

Frequent Contributor
Posts: 91

## Re: help

Input the first 8 characters of you time stamp with informat  Time8.  That converts the time to sas internal format, time in seconds.

Divide by 60 to get minutes.

data;
input stime time8.;
stime=stime/60;
cards;        ***  one hour  equals 60 min;
01:00:00
proc print; run;

60

☑ This topic is solved.