In SAS DI is there a way we could pass the environment details in form of parameters to pre and post code sections of JOB.
Currently we open the pre and post code sections of the job and we are manually changing the library names and source paths using find and replace command. We have about few 100 jobs and this manual process is highly effort intensive and error prone.
It would be great if we can get any suggestion on whether we can pass the environment variables & database paths in form of parameters which could be passed to the jobs.
We have already gone through SAS DI user guide and we could not get much help from it.
The version of product what we use is SAS DI 4.2
Example:
Thanks much!!!
You can import environment variables through the sysget() function. Another option could be to pass parameters on the SAS command line using -sysparm. If you have identical data structures in different data stores you could store the parameters in a lookup table and use it in the loop transform.
When moving jobs from one environment to the next you shouldn't have to change anything in the jobs. The only place where environment specific settings like paths should be done is in the autoexec, the config and in SAS Metadata (where you define these things once and then it gets used by all jobs).
In order for above to work you shouldn't use any fully hard coded paths in your jobs.
Let's say this is your staging area: C:\SAS\Config\Lev1\SASApp\Data\Staging
What I would do is to define the following in the autoexec:
%let lev=Lev1;
%let data=C:\SAS\Config\&lev\SASApp\Data;
And then in the External File Metadata you would define the file as:
&data\Staging\myfile.txt
....and select "double quotes" as well.
All libnames should be defined in SAS Metadata so that you have to set-up and change the paths only once and in Metadata (using SMC). No need to change anythings in the jobs after that.
Above concept worked for me in many projects.
Why are you defining different library names between SAS environments when presumably they refer to the same data, just stored in a different location? For example Production versus Development version of the same data.
If you had the same library names across your environments then you wouldn't have this problem. This is what we do where I work and it means no code changes. Also we assign all libraries in metadata, not in code - this is best practice.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.