BookmarkSubscribeRSS Feed
Aswin_K
Calcite | Level 5

Hi,

 

In one of my programs, i know the library reference associated with the Database. But i need to find the Server id that has been provided for server=option while creating the libname statement. I checked Dictionary tables and couldn't find the field which holds the server information. 

 

For example,

libname mydata informix server=year16; --> my libname statement.

But from the programs, i know only the libref name "mydata". how to retrieve the server value "year16" using the libref "mydata"

 

Thanks for you help!

3 REPLIES 3
SASKiwi
PROC Star

You are correct. You won't find the the server name in the SAS dictionary tables. A simple solution to this problem would be to use a macro variable to define your server name then you can use it anywhere in your program:

 

 

%let MyServer = year16; 

libname mydata informix server=&MyServer;

%put My Server is called: &MyServer;

 

Aswin_K
Calcite | Level 5

Thanks for the response @SASKiwi , my problem is that i am working on a macro that can be added to any program and the macro need to identify the server of the libname passed into it. The libname could have been declared anywhere in the program.

 

Thanks,

Aswin K

Tom
Super User Tom
Super User

Query the metadata tables.  You can use SASHELP.VLIBNAM view. Or with SQL you can reference it directly as DICTIONARY.LIBNAMES.

 

Here is a link to macro that will return the Engine type, Hostname and schema/database name from that table.

 

 https://github.com/sasutils/macros/blob/master/dblibchk.sas

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 2123 views
  • 0 likes
  • 3 in conversation