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,
Hi @gnrslasher37,
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".
Hi @gnrslasher37,
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".
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
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.