BookmarkSubscribeRSS Feed
thanikondharish
Fluorite | Level 6

data want ;

time='12:12:34't ;

format time time8. ;

run;

 

proc print data=want ;

format time second. ;

run;

 

 

 

If i run above program it doesn't show the value so what will we do?

 

11 REPLIES 11
thanikondharish
Fluorite | Level 6

i want to show only seconds on output by using proc pirnt

Jagadishkatam
Amethyst | Level 16

we could show the seconds in a new variable using the second function, not sure if we have a format for seconds only

 

please try the below code which will create a new variable with seconds.

 

data want ;
time='12:12:34't ;
second=second(time);
run;
Thanks,
Jag
thanikondharish
Fluorite | Level 6
i asked
is there any format for second
Jagadishkatam
Amethyst | Level 16
not, as of I remember
but definitely may be if others can help you.
Thanks,
Jag
error_prone
Barite | Level 11

Do you need the seconds-part from the time-value or the time-value in seconds?

 

If you need the later: Have you read the documents linked by @Kurt_Bremser

Kurt_Bremser
Super User

Once again: read the documentation. Time values ARE seconds, so no special format is needed. If you need to extract the seconds within a minute, use the second() function, or mod(time,60).

Reeza
Super User

@thanikondharish wrote:
i asked
is there any format for second

Time values are stored as seconds, so not having any format will display it in seconds. 

Any other format applies a style to it. Similarly, dates as stored as days. 

 

 

data want;
    time='12:12:34't;
    seconds = 34 + 12*60 + 12*60*60; *to check;
    format time time8.;
run;

title 'With time8 format';

proc print data=want;
    format time time8.;
run;

title 'With no format';

proc print data=want;
    format time;
    ;
run;
Ksharp
Super User
proc format ;
picture fmt
 low-high='%0s' (datatype=time);
run;



data want ;
time='12:12:34't ;
format time time8. ;
run;
proc print data=want ;
format time fmt. ;
run;
Ksharp
Super User
proc format ;
picture fmt
 low-high='%0s' (datatype=time);
run;



data want ;
time='12:12:34't ;
format time time8. ;
run;
proc print data=want ;
format time fmt. ;
run;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 11 replies
  • 3008 views
  • 2 likes
  • 6 in conversation