BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
boer
Calcite | Level 5

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. 

 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

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);

 

View solution in original post

2 REPLIES 2
FreelanceReinh
Jade | Level 19

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);

 

sas-innovate-white.png

Special offer for SAS Communities members

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.

 

View the full agenda.

Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1203 views
  • 0 likes
  • 3 in conversation