<?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: How to check dataset exist in libraries and run the following code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-check-dataset-exist-in-libraries-and-run-the-following/m-p/868131#M342905</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %sysfunc(exist(&amp;amp;lib..chk)) %then %do;

/* conditional code */

%end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 05 Apr 2023 05:18:57 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2023-04-05T05:18:57Z</dc:date>
    <item>
      <title>How to check dataset exist in libraries and run the following code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-check-dataset-exist-in-libraries-and-run-the-following/m-p/868113#M342896</link>
      <description>&lt;P&gt;I have like 30 libraries ( created by another macro as an initial setup). I am checking if my interested dataset exists in the library. How can I do this? The purpose of this code is, if this dataset exists then I want to run another macro/data step. I created the sample. Thank you for your suggestions, and sorry if any mistakes in my sample; I will correct them as I get suggestions.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;** Just created the libraries, for example;

libname s1 'D:\New folder';
libname s2 'D:\New folder 1';

data s1.chk;
x='y';
run;


** if dataset 'chk' in 's1' or 's2' library then the 
the following code has to run; otherwise need a note
'No dataset exists';


*&amp;amp;lib is the library where the dataset existed;

data chk_&amp;amp;lib;
set &amp;amp;lib.chk;
flag ='Y';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Apr 2023 00:46:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-check-dataset-exist-in-libraries-and-run-the-following/m-p/868113#M342896</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2023-04-05T00:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to check dataset exist in libraries and run the following code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-check-dataset-exist-in-libraries-and-run-the-following/m-p/868131#M342905</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %sysfunc(exist(&amp;amp;lib..chk)) %then %do;

/* conditional code */

%end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Apr 2023 05:18:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-check-dataset-exist-in-libraries-and-run-the-following/m-p/868131#M342905</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-04-05T05:18:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to check dataset exist in libraries and run the following code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-check-dataset-exist-in-libraries-and-run-the-following/m-p/868135#M342906</link>
      <description>&lt;P&gt;What should happen if the dataset exists in both libraries?&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2023 05:51:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-check-dataset-exist-in-libraries-and-run-the-following/m-p/868135#M342906</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2023-04-05T05:51:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to check dataset exist in libraries and run the following code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-check-dataset-exist-in-libraries-and-run-the-following/m-p/868229#M342953</link>
      <description>&lt;P&gt;if data set is present in both libraries, then it should execute the following code and create the chk_s1, chk_s2 datasets.&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;data chk_&amp;amp;lib;
set &amp;amp;lib.chk;
flag ='Y';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2023 13:15:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-check-dataset-exist-in-libraries-and-run-the-following/m-p/868229#M342953</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2023-04-05T13:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to check dataset exist in libraries and run the following code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-check-dataset-exist-in-libraries-and-run-the-following/m-p/868240#M342959</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;. This code works. However, I have an extension question. I&amp;nbsp; have 30 libraries. Is there anyway &amp;amp;lib' created automatically by using like dictionary. tables or vcolumn ? otherwise, I have to run a macro for each library.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2023 13:33:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-check-dataset-exist-in-libraries-and-run-the-following/m-p/868240#M342959</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2023-04-05T13:33:10Z</dc:date>
    </item>
  </channel>
</rss>

