BookmarkSubscribeRSS Feed
garag
Calcite | Level 5


Hi,

I would show a time in the format HHMMSS where:

HH, MM, SS have always 2 digit, I means 9:1:1 in should be 090101.

I'ev trie time but its behaviour is different.

Do there is a format that works in that way?

Many thanks.

Regards.

13 REPLIES 13
NagendraKumarK
Calcite | Level 5

Hi Garag,

Please check this


data _null_;

abc='09:01:12't;
res=compress(put(abc,time8.),':');
put res=;

run;


jdmarino
Fluorite | Level 6

This is the way I've done it, but I was hoping there was a more direct way.  Frankly I'm surprised there isn't a built-in format for this.

Peter_C
Rhodochrosite | Level 12

there is that "more direct" way

try

%put %sysfunc( putn( '9:9:9't, B8601TM )) ;

I get

090909

SAS9.2 doc can be found at http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a003169787.htm

Message was edited by: Peter Crawford showing how these formats can easily be found ---> Session ID: 1744 Session Title: VFORMAT Lets SAS® Do the Format Searching my short paper will be presented some time between 24th and 26th March 2014 in SAS Global Forum  www.sasglobalforum.org

data_null__
Jade | Level 19

I thought that one of those 8601 formats might work but I could never find it.  I remembered your search technique, I think you showed us that on SAS-L in the not too distant past, but I was too lazy to follow through.  Glad to see that you will presenting it at SGF.  The SGF reviewers did not like my ideas this year or last, but they did say they hope I enjoy the conference. Right.

art297
Opal | Level 21

DN:  The SGF reviewers obviously don't have a clear concept of what most of us want to see.  I haven't seen what may have been selected in the second go round but, from the initial listing, it was just the same old.  I've been waiting for years to see you present!

data_null__
Jade | Level 19

You haven't missed anything, but I do like to hear myself talk. :smileyshocked:

garag
Calcite | Level 5

The developers that have created SAS they never used SAS I think, because otherwise these developers, in the case they used the software they have been produced, they should choosen a name for the format more easy to find

garag
Calcite | Level 5


Hi Peter,

I'm running 9.1 and I think that the format B8601TM is not available


data _null_;
  abc='9:9:2't;
  res=put(abc,B8601TM.);
  put res=;
  run;

ERROR 48-59: The format B8601TM was not found or could not be loaded.

Thanks

art297
Opal | Level 21

: I can't recall whether it was or wasn't available in 9.1, but you might want to try it .. adding the desired length to the format.

As for the names, there are so many formats and informats, naming would be problematic for anyone.  In the case, the formats conform to the ISO 8601 standard, thus would make sense to some.

Peter_C
Rhodochrosite | Level 12

garag

why not upgrade from SAS9.1 It is so out-of-date

SAS don't charge any more when you upgrade your release (but I don't speak for SAS)

everything improves

you might have work to migrate a metadata server

but the effort is worth it

there are many more improvements than just this little  B8601TM format

garag
Calcite | Level 5

Hi NagendraKumarK,

it does not work, I get

90112

but is would get always 2 digit for the hour, 2 for minutes, 2 for hours, I mean in this case I would get 090112

Thanks

data_null__
Jade | Level 19
proc format;
  
picture todx other='%0H%0M%0s' (datatype=time);
   run;
pradeepalankar
Obsidian | Level 7

Hi, Try this :

data _null_;

format time tod.; /*just to show difference*/

time='9:1:12't;

time6=compress(put(time,tod.),':');

put "time=" time;

put "time6=" time6;

run;

output:

time=09:01:12

time6=090112

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 13 replies
  • 18141 views
  • 7 likes
  • 7 in conversation