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;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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