Bharath
Bharath

Reputation: 95

Reading files from specific folder which has got datetime stamp- sas

I have to read csv files every day which are kept in a folder with a date time stamp on it. eg: newfolder20150430023210

I have to extract these files everyday from the folder. But since the folder has got time stamp on it, I'm unable to create a macro which can read the latest file from the directory. I could create a macro of the current datetime but not the folder datetime.

eg: path:- D:\SAS\Data\Newfolder20150430023210\file.csv I need to read this path where 20150430023210 is dynamic.

thank you

Upvotes: 0

Views: 788

Answers (1)

Stig Eide
Stig Eide

Reputation: 1062

I think you need to find the newest folder first, this code wil do that:

filename f pipe "dir /B/A:D/O:-D D:\SAS\Data\Newfolder*";
data _null_;
  infile f;
  input;
  call symputx("lastDir",_infile_);
  stop;
run;

Now, you have a macrovariable "lastDir" that has the name of the folder.

Upvotes: 1

Related Questions