0
votes

I am trying to convert seconds to minutes seconds, so 123 seconds would be 2:03 (2 minutes 3 seconds). I am using SAS and need to do this in PROC SQL not a data step.

The duration (the one with the seconds) field is numeric.

Thank you

1
Are your durations ever more than an hour long? That is is the number of seconds ever more than 60*60? Is so that to you want to display for those values?Tom

1 Answers

0
votes

Use the time format.

proc sql;
    select 123 as time_numeric format=time.
         , put(123, time.) as time_char
    from sashelp.cars(obs=1)
    ;
quit;

enter image description here

If you strictly need minutes without hours:

proc sql;
    select cats(scan(put(123, time.), 2, ':'), ':', scan(put(123, time.), 3, ':') )
    from sashelp.cars(obs=1)
    ;
quit;

enter image description here