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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1354 views
  • 0 likes
  • 3 in conversation