DATA Step, Macro, Functions and more

Parametrisation challenge in SAS DI

Not applicable
Posts: 1

Parametrisation challenge in SAS DI

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


Thanks much!!!

Super User
Posts: 5,884

Re: Parametrisation challenge in SAS DI

Posted in reply to Sivasandeep

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
Respected Advisor
Posts: 4,736

Re: Parametrisation challenge in SAS DI

Posted in reply to Sivasandeep

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:


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

Super User
Posts: 3,926

Re: Parametrisation challenge in SAS DI

Posted in reply to Sivasandeep

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.

Ask a Question
Discussion stats
  • 3 replies
  • 4 in conversation