DATA Step, Macro, Functions and more

File date and time

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 14
Accepted Solution

File date and time

Hi All,

 

Have a great day...!

 

I have a column (file_name) with File names as values. Now I need to obtain each file Date and time of Created and modified.

 

 

 

INPUT Dataset

file_name

File1

File2

File3

File4

File5

 

 

Output Dataset

File_name

Moddate

File1

Xx

File2

Xx

File3

Xx

File4

Xx

File5

xx

 

 Please give me some suggestion.

 


Accepted Solutions
Solution
‎02-10-2017 04:48 AM
SAS Super FREQ
Posts: 683

Re: File date and time

Hi

 

You can take this code

data have;
  length filename $ 1024;
  input
    filename
  ;
  cards;
c:\temp\anchor.pdf
c:\temp\Book1.csv
;

data a;
  set have;
  rcs = filename("fileref", filename);
  msgs = sysmsg();
  fid=fopen('fileref');
  Bytes=finfo(fid,'File Size (bytes)');
  crdate=finfo(fid,'Create Time');
  moddate=finfo(fid,'Last Modified');
  rc = fclose(fid);
  rcc = filename("fileref");
run;

proc print;
run;

View solution in original post


All Replies
PROC Star
Posts: 551

Re: File date and time

Are the files all located in the same directory? Smiley Happy

Occasional Contributor
Posts: 14

Re: File date and time

yes they are in same folder.

SAS Super FREQ
Posts: 683

Re: File date and time

Hi

 

Have a look here http://support.sas.com/kb/40/934.html

 

Bruno

 

Solution
‎02-10-2017 04:48 AM
SAS Super FREQ
Posts: 683

Re: File date and time

Hi

 

You can take this code

data have;
  length filename $ 1024;
  input
    filename
  ;
  cards;
c:\temp\anchor.pdf
c:\temp\Book1.csv
;

data a;
  set have;
  rcs = filename("fileref", filename);
  msgs = sysmsg();
  fid=fopen('fileref');
  Bytes=finfo(fid,'File Size (bytes)');
  crdate=finfo(fid,'Create Time');
  moddate=finfo(fid,'Last Modified');
  rc = fclose(fid);
  rcc = filename("fileref");
run;

proc print;
run;
Occasional Contributor
Posts: 14

Re: File date and time

Hi,

 

Thank you.

 

 

I tried doing it. But when I did it I am getting following note:

 

Note: Arguement 1 to function finfo at line xxx column xx is invalid.

 

Any idea on what reason this note occurs 

Occasional Contributor
Posts: 14

Re: File date and time

Hi Bruno_sas,

Thank you.

I too used the same program, I think i was out of the world by not seeing the path.

When the path was corrected it worked fine.

Thanks a lot.
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 171 views
  • 0 likes
  • 3 in conversation