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?
Maxim 1 & Maxim 2.
From where do you get the notion that a "second" format exists?
What is a SAS time value?
This will give you a clue.
i want to show only seconds on output by using proc pirnt
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;
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?
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).
@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;
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;
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;
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.