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.
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.
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 ?
Thats part of the ISO standard; you can replace it with the translate() function.
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:
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.
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!
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.
Ready to level-up your skills? Choose your own adventure.