We have a requirment to use same jobs for same type of tables from two different database schemas of SQL Server. So can we use the same jobs by parameterizing the library reference of the tables in SAS DI? Is this possible?
Not directly in DIS. Table names is possible though.
Depending on how you are setting the parameter, you could have the same libname defined with schema as a macro/environtment variable. With this scenario, you probably need to mark this libname as pre-assigned, and handle the logic in appserer:
Same basic idea like Linus:
Define a library where you use a macro variable name as schema name. Then define a default value for this macro in the autoexec (so that you can register tables).
Do not pre-assign the library as this will allow you to set the value in the schemaname macro variable during run time at the beginning of your job (eg. as parameter of the DIS job and then you have a outer loop job calling this job passing the schema name you need).
Patrick,
We are creating a library for SQL server database using ODBC Engine. Where to define the macro variable for the schema while creating the Library?
Sadly, there is no silver bullet.
One thing to consider is how do want/need to access the data when loaded? What kind of clients/jobs do you have?
What is the difference between those schemas, which to use when, and why?
If you have parameters in the jobs, only those jobs will be able to access the data.
Perhaps do you need some default behavior, which could be set by some logic in the appserver_autoexec.
@Sandhyaa
In the library definition under Data Server/Database Schema use instead of the schema name something like &db_schema_1. Then in the autoexec define and populate this macro variable with the schema name you want to use for registering the tables.
I would use an autoexec which gets processed by all servers (at least the batch, stored process and workspace server should get it) so I would use ..\Config\Lev<n>\<server, eg. SASApp>\appserver_autoexec_usermods.sas and then
%let db_schema_1=<schema name>;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.