<?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 In SAS Viya 4 I want to check if a folder exists in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/In-SAS-Viya-4-I-want-to-check-if-a-folder-exists/m-p/970216#M377050</link>
    <description>&lt;P&gt;My starting point is the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data _null_ works as expected, but the filename line gives an error, if the folder does not exist.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I wrap it in an %if %then statement? How can I check for the existence of the folder?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename myfolder FILESRVC FOLDERPATH= "/Reporting/DEV/REG/ABCD/out_json_backup";

data _null_;
  dir_id=exist("myfolder");
  if dnum(dir_id)=0 then do;
       /* do what is necessary if folder is empty */
%put 'hello';
    end;
  rc=dclose(dir_id);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 04 Jul 2025 09:57:05 GMT</pubDate>
    <dc:creator>acordes</dc:creator>
    <dc:date>2025-07-04T09:57:05Z</dc:date>
    <item>
      <title>In SAS Viya 4 I want to check if a folder exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/In-SAS-Viya-4-I-want-to-check-if-a-folder-exists/m-p/970216#M377050</link>
      <description>&lt;P&gt;My starting point is the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data _null_ works as expected, but the filename line gives an error, if the folder does not exist.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I wrap it in an %if %then statement? How can I check for the existence of the folder?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename myfolder FILESRVC FOLDERPATH= "/Reporting/DEV/REG/ABCD/out_json_backup";

data _null_;
  dir_id=exist("myfolder");
  if dnum(dir_id)=0 then do;
       /* do what is necessary if folder is empty */
%put 'hello';
    end;
  rc=dclose(dir_id);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Jul 2025 09:57:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/In-SAS-Viya-4-I-want-to-check-if-a-folder-exists/m-p/970216#M377050</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2025-07-04T09:57:05Z</dc:date>
    </item>
    <item>
      <title>Re: In SAS Viya 4 I want to check if a folder exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/In-SAS-Viya-4-I-want-to-check-if-a-folder-exists/m-p/970222#M377051</link>
      <description>&lt;P&gt;Please check the docs!&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;exist can be used with datasets and views only&lt;/LI&gt;
&lt;LI&gt;before using dnum and dclose you need to use dopen&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jul 2025 11:29:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/In-SAS-Viya-4-I-want-to-check-if-a-folder-exists/m-p/970222#M377051</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2025-07-04T11:29:17Z</dc:date>
    </item>
  </channel>
</rss>

