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

Hello everyone,

 

I am working with a string variable that has cpu time.  I am trying to aggregate them together but I can't convert the string to time format or sum them together.  Can anyone offer a clue?

 

data sas;

input timeval $ ;

datalines;

 

01:24.3

02:57.4

02:41.0

03:25.7

01:17.0

04:06.0

03:44.1

02:54.0

03:04.3

03:07.9

01:20.0

04:10.5

03:40.7

03:20.4

02:16.4

02:31.6

01:54.0

01:47.9

03:48.8

10:38.2

01:00.2

01:03.5

01:03.8

01:11.1

01:00.1

01:13.9

01:01.8

03:13.8

06:37.6

07:29.9

03:52.7

01:03.6

01:30.7

01:34.9

02:08.1

01:00.4

01:02.8

01:00.7

01:00.2

01:05.0

01:01.0

01:01.8

01:07.8

01:06.6

01:06.8

01:13.6

01:01.1

01:01.7

01:04.3

01:00.0

01:01.9

01:01.3

01:01.3

01:01.3

01:01.4

01:02.8

02:16.4

02:26.9

01:02.8

01:31.8

01:52.2

01:50.5

01:58.6

01:45.5

01:58.6

01:35.5

01:56.5

01:58.7

01:30.8

01:35.9

01:49.1

01:56.2

01:31.9

01:56.4

01:56.3

01:31.6

01:39.2

01:45.1

01:59.1

01:49.6

01:36.9

01:58.4

01:59.9

01:53.2

01:42.7

02:00.0

01:57.1

01:48.5

01:44.5

01:56.5

01:56.0

01:40.0

01:45.7

01:55.9

01:55.3

01:48.0

01:56.8

01:00.0

01:00.4

01:00.1

01:00.2

01:00.1

01:00.1

01:00.0

01:09.6

01:00.5

01:00.5

01:00.5

01:00.8

01:00.1

01:01.2

01:02.6

01:00.3

01:00.4

01:00.3

01:00.2

01:00.1

01:00.2

01:00.5

01:00.3

01:00.2

01:00.2

01:00.0

01:00.7

01:00.8

01:00.2

01:00.5

01:00.5

01:00.5

01:00.4

01:00.6

01:00.5

01:00.7

01:00.6

01:00.4

01:00.3

01:02.2

01:00.4

01:00.6

01:00.4

01:00.6

01:00.9

01:00.6

01:00.2

01:00.7

01:00.8

01:00.3

01:00.4

01:00.5

01:00.6

01:00.4

01:00.5

01:00.3

01:24.5

01:19.5

01:01.3

01:07.5

01:17.3

01:20.8

01:29.8

01:25.8

01:21.0

01:20.4

01:17.9

01:17.7

01:23.2

01:07.4

01:24.3

01:20.4

01:19.9

01:16.5

01:23.7

01:23.7

01:24.3

01:20.1

01:25.1

01:23.3

01:22.4

01:18.7

01:24.9

01:26.0

01:18.3

01:03.9

01:22.9

01:20.3

01:33.0

01:17.9

01:23.8

01:18.4

01:23.8

01:13.5

01:24.8

01:20.1

01:24.1

01:20.0

01:25.9

01:20.5

01:22.0

01:26.6

01:21.3

01:05.2

01:27.3

01:13.5

01:26.1

01:27.0

01:26.7

01:24.2

01:25.4

01:25.9

01:25.8

01:26.0

01:26.7

01:25.4

01:26.4

01:24.2

01:20.7

01:25.8

01:26.3

01:26.4

01:29.1

01:26.4

01:27.1

01:26.0

01:26.5

;

run;

 

data rest;

set sas;

a_timeval=input(timeval, mmss.);

 

 

run;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
data want;
input timeval $10.;
time=input(cats('00:',timeval),time10.1);
format time time10.1;
datalines;
...
;

You should be able to sum these.

 

proc summary data=have;
    var time;
    output out=want sum=sum_time;
run;
--
Paige Miller

View solution in original post

6 REPLIES 6
PaigeMiller
Diamond | Level 26
data want;
input timeval $10.;
time=input(cats('00:',timeval),time10.1);
format time time10.1;
datalines;
...
;

You should be able to sum these.

 

proc summary data=have;
    var time;
    output out=want sum=sum_time;
run;
--
Paige Miller
novinosrin
Tourmaline | Level 20

Hi @yo1  If you just want minutes and seconds , just use time5. informat

 

data rest;

set sas;

a_timeval=input(timeval, time5.);
 
format a_timeval time5.;
run;
yo1
Obsidian | Level 7 yo1
Obsidian | Level 7
FYI- I tried your code but it didn't work. the new variable had missing values and I got warning messages in the log.
novinosrin
Tourmaline | Level 20

Oh sorry my bad. Well I am pleased you have a working solution. 

yo1
Obsidian | Level 7 yo1
Obsidian | Level 7
Thank you friend! Your support was still Awesome!

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
  • 6 replies
  • 1667 views
  • 2 likes
  • 3 in conversation