BookmarkSubscribeRSS Feed
brighterlight
Fluorite | Level 6

Hi everyone,

 

For the code found in this website, the output of the created date is in the fomat of 26Sep2018:18:06:37. 

 

I would like to ask if it is possible to have the output in this format (26/09/2018:18:06:37)  instead? 

 

Thanks in advance.

 

 

http://support.sas.com/kb/40/934.html

 

data a(drop=fid);                                                                                                                       
   infile fileref truncover obs=1;                                                                                                       
   fid=fopen('fileref');                                                                                                                 
   Bytes=finfo(fid,'File Size (bytes)');                                                                                                 
   crdate=finfo(fid,'Create Time');                                                                                                      
   moddate=finfo(fid,'Last Modified');                                                                                                   
run;                                                                                                                                    
                                                                                                                                        
proc print;                                                                                                                             
run;

 

 

Edit by KB: fixed the link.

 

 

4 REPLIES 4
Kurt_Bremser
Super User

Try this:

crdate=input(finfo(fid,'Create Time'),datetime19.);
format crdate e8601dt20.;

It gives you a timestamp formatted to ISO standards. You can apply any other datetime format available.

brighterlight
Fluorite | Level 6

Hi thanks for the reply. 

 

I am able to obtain this 

2018-09-26T18:05:45 

 

Can I ask why is there a letter 'T' in between ? 

Patrick
Opal | Level 21

@brighterlight

SAS Datetime values are stored a numeric values representing a count of seconds since 1/1/1960. A format is only for print/display of such a SAS Datetime value.

SAS offers quite a collection of formats for printing datetime values:

https://support.sas.com/documentation/cdl/en/leforinforref/64790/HTML/default/viewer.htm#n0p2fmevfgj...

 

You best stick to one of the OOTB formats from above BUT if you really must then you can also create your own picture format (using Proc Format). The disadvantage of this: You need to ensure that this format is available whenever you use it so you either store it in a permanent catalog and add the catalog to the format search path (option FMTSEARCH) or you ensure that the code creating the picture format gets always executed when you use the format. ...but: if then storing the data in a permanent table with the format assigned to the variable you still will need the format itself stored in a permanent catalog.

 

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

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 4 replies
  • 2142 views
  • 0 likes
  • 3 in conversation