BookmarkSubscribeRSS Feed
dkb
Quartz | Level 8 dkb
Quartz | Level 8

Hello Community,

Environment: DI Studio 4.8, on a Unix platform

 

I'd like to create a user defined transform, or piece of user code, that checks the last modified date of an external file (so I can decide whether it should be reloaded). This is going to be used for multiple external files, so it needs to be generalised and neatly packaged, not a one-off bit of hardcoding.

 

If I have a physical file name, I can use FINFO to get what I need. 

 

But an external file can't be connected to the input of a user defined transform, and while it can be connected to the input of a user defined code transform, its name and physical location aren't then made available in macro variables to the code within. 

 

Any suggestions as to how I might get hold of the file name, or another approach to getting the last mod date?

 

Thanks,

Dave

1 REPLY 1
LinusH
Tourmaline | Level 20

Hi,

usually, for this kind of logic, I think it better belongs to your scheduling tool. Most of them have file events that can trigger jobs depening on things like arrival.

 

That said, I also recognize the (weird?) fact that the User Written Transformation doesn't accept External Files.

Using Pre-code to the File RFeade is to little avail since almos no useful macros are defined here, especially not the file name.

 

Allthough, the User Written Code might work. For some reason, you get a lot of automatic macros here. So one way to wrap it up is to write a mcaro that you stored in a SASAUTOS location (typically configdir/SASApp/SASEnvironment/SASMAcro.

Then you need to instruct your users to simply add a call to that macro in the User Written Code Transformatino that is linked to the External File Object.

Data never sleeps

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 679 views
  • 0 likes
  • 2 in conversation