BookmarkSubscribeRSS Feed
Flappyduck
Calcite | Level 5

Hi All,

 

i've got a job that runs in DI Studio every 12 hours, it reads in and processes loads of hourly files I.E (Data_2019073101 (1AM), Data_2019073102 (2AM) then spits it out into one master table. What i'm trying to do is add these hourly times to the output of the data in the master table when its complete. I was thinking of a file lister, but realised it won't work because when the job runs it will bring in 12 hours of files at once and won't know where to put the correct hour based on the data.

 

Any ideas?

 

Thanks

1 REPLY 1
Kurt_Bremser
Super User

I don't know how to do it with the DI Studio interface, but this is the basic code structure I would use to read multiple files and keep file information:

%let infilepath=somewhere;
%let basename=Data_%sysfunc(today(),yymmddn8.);

data input;
infile "&infilepath./&basename.*" filename=fname;
/* input processing etc. */
filetime = dhms(today(),input(substr(fname,length(fname)-1),2.),0,0);
format filetime e8601dt19.;
run;

The filename= option in the infile statement instructs SAS to create a variable (which will not be included in the dataset) that holds the name of the currently processed file.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 608 views
  • 0 likes
  • 2 in conversation