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.

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 1474 views
  • 0 likes
  • 3 in conversation