I want to track the SAS job name which was executed, job start time, job end time, job folder location and job status after the execution of every job in SAS DI 4.9. Is there any table which automatically pulls this details for every job? If yes, I can pull those information via SAS code which I can place in 'post code' section
Objective is to get these details from SAS and insert it into the SQL table.
I've seen people implementing such stuff via a custom transformation which they just add at the start and beginning of a DIS job - or if you don't need an entry if a job fails then just at the end. I've seen other people doing it via macro calls just added as pre- and post-code to the DIS job.
Transformation Return Code Check generates SAS code which gives you a very good start to develop such custom code.
BUT: DIS jobs get scheduled and run in batch. Many schedulers maintain a repository where such execution information gets stored. I believe you only should go for a DIS only solution if the scheduler doesn't maintain the information you need. LSF for example got this information and you can query it and extract the info into a SAS table.
Because the scheduling process is the parent, your SAS job can terminate in any way and you still maintain all the execution information. For example if an abort statement gets executed somewhere in the middle of your job (i.e. by a lookup transformation) then the node at the end of the DIS job writing status information gets never executed - but the scheduler will have the information that the job terminated with return code n.
Add DIS transformation Return Code Check to any DIS job, create a new action and select "Send Entry to a Dataset". The generated macro code under the code tab will give you a very good starting point to implement what you're after.
Or if what comes out of the box is enough for you then you can also use the DIS job level status handling. You get there just by right clicking on the job canvas.
You can also select an action of custom - and custom could then be a SAS macro where you're doing whatever you need.
A) Your question is not clear
B) You really need to start and look into and understand DIS generated code to get a better grasp what's available to you.
If you don't see what you need in generated code then "play around" changing options and then revisit the generated code and check if that gives you the required information.
You could of course always query SAS metadata for additional metadata information. Given that a deployed job (.sas file) doesn't need to be in sync with its originating metadata or that for moving a job (.sas file) the originating metadata doesn't necessarily need to be migrated as well, I wouldn't consider such metadata queries as good idea.
And my answer is that you should ask a new question as a new question, that you should inspect the DIS generated code to determine if there is already a macro variable created that has this information in it. If not then you would need to query SAS Metadata for additional SAS Metadata information. DIS generates the metadata job ID into your code (&jobID) so you've got a very good starting point for doing such a metadata query (but as said: job metadata does not need to be in sync with the deployed .sas file so....).
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.