Hi all,
In SAS management console we have the option to "Deploy SAS datastep program"
while deploying we choose the "Source File" location where the source sas code currently resides.
when we redeploy the job it picks up the updated code from the "Source File" location and deploys the job.
My question is , is there i way i can find out what was the Source File location of a deployed job ?
Thanks.
This program could help:
/* Edit with connection information for the Metadata Server. */
options metaserver="meta.demo.sas.com"
metaport=8561
metauser="sasadm@saspw"
metapass="password"
metarepository=Foundation
metaprotocol=bridge;
/* End Edit. */
data source;
keep job_name source; /* Retain only the job name and it's source code full path. */
/* Initialize variables. */
length type id job_uri job_name file_uri file_name dir_uri path $ 50;
call missing (of _character_);
obj="omsobj:Job?@Id contains '.'"; /* Search criteria for Jobs. */
job_count=metadata_resolve(obj,type,id); /* Count all jobs. Only run loop if jobs exist. */
if job_count > 0 then do i=1 to job_count; /* Loop: For each job found, get attributes and associations. */
rc=metadata_getnobj(obj,i,job_uri);
rc=metadata_getattr(job_uri,"Name",job_name); /* Get job name. */
rc=metadata_getnasn(job_uri,"SourceCode",1,file_uri); /* Get file Metadata object id. */
rc=metadata_getattr(file_uri,"Name",file_name); /* Get file name. */
rc=metadata_getnasn(file_uri,"Directories",1,dir_uri); /* Get directory Metadata object id. */
rc=metadata_getattr(dir_uri,"DirectoryName",path); /* Get path to directory. */
source=catx('/',path,file_name); /* combine directory path and file name to create full path to file.*/
output;
end; /* End loop. */
else put "WARN: No jobs found in Metadata."; /* If no jobs are found, write a message to the log. */
run;
Please have a look at this paper.
It will answer your questions and more https://www.aii-3.com/wp-content/uploads/2020/02/Schedule-SAS-Jobs-Using-Schedule-Manager.pdf
This program could help:
/* Edit with connection information for the Metadata Server. */
options metaserver="meta.demo.sas.com"
metaport=8561
metauser="sasadm@saspw"
metapass="password"
metarepository=Foundation
metaprotocol=bridge;
/* End Edit. */
data source;
keep job_name source; /* Retain only the job name and it's source code full path. */
/* Initialize variables. */
length type id job_uri job_name file_uri file_name dir_uri path $ 50;
call missing (of _character_);
obj="omsobj:Job?@Id contains '.'"; /* Search criteria for Jobs. */
job_count=metadata_resolve(obj,type,id); /* Count all jobs. Only run loop if jobs exist. */
if job_count > 0 then do i=1 to job_count; /* Loop: For each job found, get attributes and associations. */
rc=metadata_getnobj(obj,i,job_uri);
rc=metadata_getattr(job_uri,"Name",job_name); /* Get job name. */
rc=metadata_getnasn(job_uri,"SourceCode",1,file_uri); /* Get file Metadata object id. */
rc=metadata_getattr(file_uri,"Name",file_name); /* Get file name. */
rc=metadata_getnasn(file_uri,"Directories",1,dir_uri); /* Get directory Metadata object id. */
rc=metadata_getattr(dir_uri,"DirectoryName",path); /* Get path to directory. */
source=catx('/',path,file_name); /* combine directory path and file name to create full path to file.*/
output;
end; /* End loop. */
else put "WARN: No jobs found in Metadata."; /* If no jobs are found, write a message to the log. */
run;
The SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment.
Learn how to install the SAS Viya CLI and a few commands you may find useful in this video by SAS’ Darrell Barton.
Find more tutorials on the SAS Users YouTube channel.