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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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