BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
PeterBr
Obsidian | Level 7

I have a variable time which represents total elapsed time, not a time on the 24hr clock. For example, 1459 means 14 hours and 59 minutes elapsed and 9 simply means 9 minutes elapsed. It came in as a string and I am trying to convert it to a numerical value in total minutes. Below is the have and want data. I am struggling to find informats that aren't based on the 24hr clock.

 

 data have;
 input claim_id $ time $;
 cards;
 3 9
 2 14
 98 349
 99 1459
 ;
 run;
 data want;
 input claim_id $ time $ time_min;
 cards;
 3 9 9
 2 14 14
 98 349 229
 99 1459 899
 ;
 run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
smantha
Lapis Lazuli | Level 10
data have;
 input claim_id $ time ;
 if time > 60 then do;
  time=(int(time/100)*60)+mod(time,100)
 end;
 cards;
 3 9
 2 14
 98 349
 99 1459
 ;
 run;

View solution in original post

4 REPLIES 4
ballardw
Super User

Consider:

data have;
 input claim_id $ time ;
 time = time*60;
 format time time.;
 cards;
 3 9
 2 14
 98 349
 99 1459
 ;
 run;

SAS time values are stored as a number of seconds. So multiply minutes by 60. Or

 

time_min = input(time, best.)*60;

if your value is character already.

smantha
Lapis Lazuli | Level 10
data have;
 input claim_id $ time ;
 if time >60 then do;
   time=int(time/100)+mod(time,100);
 end;
 cards;
 3 9
 2 14
 98 349
 99 1459
 ;
 run;
smantha
Lapis Lazuli | Level 10
data have;
 input claim_id $ time ;
 if time > 60 then do;
  time=(int(time/100)*60)+mod(time,100)
 end;
 cards;
 3 9
 2 14
 98 349
 99 1459
 ;
 run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 4 replies
  • 1598 views
  • 2 likes
  • 4 in conversation