<?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 Re: Avoiding duplicate caslib errors in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Avoiding-duplicate-caslib-errors/m-p/633304#M187869</link>
    <description>&lt;P&gt;Use the function &lt;FONT face="courier new,courier"&gt;CLIBEXIST(session name,caslib name)&lt;/FONT&gt; to check if the CASLIB already exists.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %sysfunc(clibexist(mySession,&amp;amp;schema)) %then %do;
  caslib &amp;amp;schema. drop;
%end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 19 Mar 2020 15:06:43 GMT</pubDate>
    <dc:creator>RichardDeVen</dc:creator>
    <dc:date>2020-03-19T15:06:43Z</dc:date>
    <item>
      <title>Avoiding duplicate caslib errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Avoiding-duplicate-caslib-errors/m-p/633233#M187838</link>
      <description>&lt;P&gt;I have some code to extract data from Oracle tables. I want to set each table as a Viya data source in a caslib but they have different authdomain credentials so I'm using a macro loop.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let auth_list=
TABLEAUTH1
TABLEAUTH2
;

%let path=ORA_LIB;

%macro ora_libs;
%local i;
%do i=1 %to %sysfunc(countw(&amp;amp;auth_list));
  	%let authdomain = %scan(&amp;amp;auth_list, &amp;amp;i);
   	%let schema = &amp;amp;authdomain.;
&lt;BR /&gt;/* loop through each schema */
caslib &amp;amp;schema. drop;

caslib &amp;amp;schema. datasource=(
    srctype="oracle",
    authdomain=&amp;amp;authdomain. path=&amp;amp;path. schema=&amp;amp;schema.
    );&lt;BR /&gt;[...]&lt;BR /&gt;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;First time through the code runs fine, each pass sets up the caslib and connects to the table. But if I try to re-run the code without dropping the caslibs first I get an error telling me I am creating a duplicate caslib.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ERROR: Duplicate Caslib
ERROR: Could not add caslib 'TABLEAUTH1'. Make sure that the caslib does not already exist and that you have permissions to add 
        caslibs to Cloud Analytic Services.
ERROR: The action stopped due to errors.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I can get round this by using caslib &lt;EM&gt;schema&amp;nbsp;&lt;/EM&gt;drop; - but that gives errors on the first pass when the lib is not there!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ERROR: The caslib TABLEAUTH1 does not exist in this session.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any thoughts on how to resolve this without things getting too complicated? I can live with the 'caslib does not exist' error but it will be neater not to have to.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Mar 2020 12:24:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Avoiding-duplicate-caslib-errors/m-p/633233#M187838</guid>
      <dc:creator>lancman</dc:creator>
      <dc:date>2020-03-19T12:24:08Z</dc:date>
    </item>
    <item>
      <title>Re: Avoiding duplicate caslib errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Avoiding-duplicate-caslib-errors/m-p/633304#M187869</link>
      <description>&lt;P&gt;Use the function &lt;FONT face="courier new,courier"&gt;CLIBEXIST(session name,caslib name)&lt;/FONT&gt; to check if the CASLIB already exists.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %sysfunc(clibexist(mySession,&amp;amp;schema)) %then %do;
  caslib &amp;amp;schema. drop;
%end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Mar 2020 15:06:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Avoiding-duplicate-caslib-errors/m-p/633304#M187869</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2020-03-19T15:06:43Z</dc:date>
    </item>
    <item>
      <title>Re: Avoiding duplicate caslib errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Avoiding-duplicate-caslib-errors/m-p/633318#M187870</link>
      <description>I knew there must be a simple solution!&lt;BR /&gt;&lt;BR /&gt;Thank you.&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Mar 2020 15:17:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Avoiding-duplicate-caslib-errors/m-p/633318#M187870</guid>
      <dc:creator>lancman</dc:creator>
      <dc:date>2020-03-19T15:17:05Z</dc:date>
    </item>
  </channel>
</rss>

