Good day
I need to convert a large data base from SAS time format eg (4:55:59.00) to minutes only so that it is a numerical variable. That is the 4 hour 55 minutes 59 seconds should be rounded to 4 hour 56 minutes which is 296 minutes. Final answer 296.
All time in seconds is to be rounded up (as above). Also if time is 4:55:10.00 (4 hour 55 minutes 10 seconds) would be 4 hour 56 minutes. Note decimal between seconds and split seconds.
Good day, @boer, and welcome to the SAS Support Communities!
SAS time values are measured in seconds, so if you need minutes, divide by 60. The CEIL function will do the rounding you describe (assuming non-negative values).
Example:
data have;
input t :time.;
format t time12.2;
cards;
4:55:59.00
4:55:10.00
4:55:00.01
4:55:00.00
;
data want;
set have;
m=ceil(t/60);
run;
Edit: If t in your data is a character variable, use the INPUT function to create SAS time values from it:
m=ceil(input(t,time32.)/60);
Good day, @boer, and welcome to the SAS Support Communities!
SAS time values are measured in seconds, so if you need minutes, divide by 60. The CEIL function will do the rounding you describe (assuming non-negative values).
Example:
data have;
input t :time.;
format t time12.2;
cards;
4:55:59.00
4:55:10.00
4:55:00.01
4:55:00.00
;
data want;
set have;
m=ceil(t/60);
run;
Edit: If t in your data is a character variable, use the INPUT function to create SAS time values from it:
m=ceil(input(t,time32.)/60);
Be sure which of the rounding functions (FLOOR, ROUND, CEIL) you want to use.
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.