BookmarkSubscribeRSS Feed
Sivasandeep
Calcite | Level 5

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!!!

3 REPLIES 3
LinusH
Tourmaline | Level 20

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.

Data never sleeps
Patrick
Opal | Level 21

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.


SASKiwi
PROC Star

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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 775 views
  • 9 likes
  • 4 in conversation