<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How can i retrieve a Library for the path of an ODBC? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-can-i-retrieve-a-Library-for-the-path-of-an-ODBC/m-p/788389#M252064</link>
    <description>&lt;P&gt;I have an ODBC connection that connects to Oracle Database.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In SAS, i connect to this ODBC connection with the following statement.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;libname staging oracle authdomain="OracleAuth" path='dubaiserver.sas.com';&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want to do is to not hardcode the username, password, and library path in the code.&lt;/P&gt;&lt;P&gt;However, I am having a hardtime to retrieve the library path here. I can find this path in SAS Management Console by opening the library "staging".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I see some guides that path can easily be resolved. However, the Database path is different from server host.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to make the "path" dynamic?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My desired libname statement is:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;libname staging oracle authdomain="OracleAuth" path=DBPath;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Jan 2022 03:34:08 GMT</pubDate>
    <dc:creator>StickyRoll</dc:creator>
    <dc:date>2022-01-05T03:34:08Z</dc:date>
    <item>
      <title>How can i retrieve a Library for the path of an ODBC?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-i-retrieve-a-Library-for-the-path-of-an-ODBC/m-p/788389#M252064</link>
      <description>&lt;P&gt;I have an ODBC connection that connects to Oracle Database.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In SAS, i connect to this ODBC connection with the following statement.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;libname staging oracle authdomain="OracleAuth" path='dubaiserver.sas.com';&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want to do is to not hardcode the username, password, and library path in the code.&lt;/P&gt;&lt;P&gt;However, I am having a hardtime to retrieve the library path here. I can find this path in SAS Management Console by opening the library "staging".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I see some guides that path can easily be resolved. However, the Database path is different from server host.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to make the "path" dynamic?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My desired libname statement is:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;libname staging oracle authdomain="OracleAuth" path=DBPath;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 03:34:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-i-retrieve-a-Library-for-the-path-of-an-ODBC/m-p/788389#M252064</guid>
      <dc:creator>StickyRoll</dc:creator>
      <dc:date>2022-01-05T03:34:08Z</dc:date>
    </item>
    <item>
      <title>Re: How can i retrieve a Library for the path of an ODBC?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-i-retrieve-a-Library-for-the-path-of-an-ODBC/m-p/788392#M252066</link>
      <description>&lt;P&gt;If you have a different database then you would also need a different authdomain.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need this library regularly then best define it in SAS metadata - under a different libref though.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What you always can do is point one libref to another. Something like: libname mystg (staging).&lt;/P&gt;
&lt;P&gt;The library pre-defined in SAS metadata doesn't need to be pre-assigned. You can always use it via the SAS Meta engine and liburi (and then just assign the libref of your desire).&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 04:20:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-i-retrieve-a-Library-for-the-path-of-an-ODBC/m-p/788392#M252066</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-01-05T04:20:17Z</dc:date>
    </item>
    <item>
      <title>Re: How can i retrieve a Library for the path of an ODBC?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-i-retrieve-a-Library-for-the-path-of-an-ODBC/m-p/788394#M252067</link>
      <description>&lt;P&gt;If you were using an ODBC connection then you would be using the ODBC engine on your LIBNAME statement. Since you use the ORACLE engine, that means you interface with the Oracle client software installed on your SAS server. The client software contains a file called TNSNAMES.ORA which is where all of the Oracle paths are defined.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any new database paths first need to be defined in TNSNAMES.ORA. Then you can try them out in a SAS LIBNAME statement. It is best to trial new database connections in a LIBNAME before defining them in SAS metadata.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 05:10:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-i-retrieve-a-Library-for-the-path-of-an-ODBC/m-p/788394#M252067</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-01-05T05:10:23Z</dc:date>
    </item>
    <item>
      <title>Re: How can i retrieve a Library for the path of an ODBC?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-i-retrieve-a-Library-for-the-path-of-an-ODBC/m-p/788405#M252075</link>
      <description>&lt;P&gt;If you are looking to extract the library definition from metadata, then this macro will help (and it is configured for Oracle libname engines):&amp;nbsp;&amp;nbsp;&lt;A href="https://core.sasjs.io/mm__assigndirectlib_8sas_source.html" target="_blank"&gt;https://core.sasjs.io/mm__assigndirectlib_8sas_source.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We use it in &lt;A href="https://datacontroller.io" target="_self"&gt;Data Controller for SAS&lt;/A&gt; to enable direct connections using the relevant system account.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the extract:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%else %if &amp;amp;engine=ORACLE %then %do;
  %put NOTE: Obtaining &amp;amp;engine library details;
  data _null_;
    length assocuri1 assocuri2 assocuri3 authdomain path schema $256;
    call missing (of _all_);
 
    /* get auth domain */
    rc=metadata_getnasn("&amp;amp;liburi",'LibraryConnection',1,assocuri1);
    rc=metadata_getnasn(assocuri1,'Domain',1,assocuri2);
    rc=metadata_getattr(assocuri2,"Name",authdomain);
    call symputx('authdomain',authdomain,'l');
 
    /* path */
    rc=metadata_getprop(assocuri1,
      'Connection.Oracle.Property.PATH.Name.xmlKey.txt',path);
    call symputx('path',path,'l');
 
    /* schema */
    rc=metadata_getnasn("&amp;amp;liburi",'UsingPackages',1,assocuri3);
    rc=metadata_getattr(assocuri3,'SchemaName',schema);
    call symputx('schema',schema,'l');
  run;
  %put NOTE: Executing the following:/; %put NOTE-;
  %put NOTE- libname &amp;amp;libref ORACLE path=&amp;amp;path schema=&amp;amp;schema;
  %put NOTE-     authdomain=&amp;amp;authdomain;
  %put NOTE-;
  libname &amp;amp;libref ORACLE path=&amp;amp;path schema=&amp;amp;schema authdomain=&amp;amp;authdomain;
%end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Jan 2022 07:22:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-i-retrieve-a-Library-for-the-path-of-an-ODBC/m-p/788405#M252075</guid>
      <dc:creator>AllanBowe</dc:creator>
      <dc:date>2022-01-05T07:22:30Z</dc:date>
    </item>
  </channel>
</rss>

