In SAS DIS, I want to reference the job name in code. I know that the global variable etls_jobName
contains this information, but when I assign this value to a field and view the output, I get '.'.
Ultimately, I'd also like to be able to get the path name (in the folder structure of the job) and I'm not sure where that sort of information lives.
Much Gratitude.
For the job flow metadata path, you can try using the below code. The code picks up job name from the &etls_jobName macro variable and extracts metadata folder path of the job. To know more about the functions that are being used, please refer to the SAS Language Interfaces to Metadata. Hope this helps!
data path_output;
length jobName $ 100 uri headuri $ 256 jobPath head_path $ 500 ;
jobName="&etls_jobName";
rcJob =metadata_getnobj("omsobj:Job?@Name ='&etls_jobName'",1,uri);
rcHead=metadata_getnasn(uri,"Trees",1,headuri);
rcPath=metadata_getattr(headuri,"Name",jobPath);
rcHead = 1;
do while(rcHead>0);
rcHead=metadata_getnasn(headuri,"ParentTree",1,headuri);
rcPath=metadata_getattr(headuri,"Name",head_path);
if (rcHead>0) then jobPath = catx('/',head_path,jobPath);
end;
output;
keep jobName jobPath;
run;
proc print;
run;
UPDATE:
If Job Flow URI needs to be picked based on Job Flow name then use what is show in the code above i.e.:
rcJob =metadata_getnobj("omsobj:Job?@Name ='&etls_jobName'",1,uri);
If Job Flow URI needs to be picked based on Metadata id then use :
rcJob =metadata_getnobj("omsobj:Job?@Id ='&jobID'",1,uri);