<?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 Can MODIFY and REPLACE Read Filenames Recursively? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-Can-MODIFY-and-REPLACE-Read-Filenames-Recursively/m-p/717317#M221807</link>
    <description>&lt;P&gt;It is not really "recursive" in the classical meaning of that term.&amp;nbsp; What is is doing to appending records to the end of the dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A normal data step will stop when it reads past the end of the input dataset (or input file when using INPUT statement).&amp;nbsp; In this step since you are modifying the input dataset instead of writing to a new dataset the OUTPUT statements are causing extra observations to added to the input dataset.&amp;nbsp; So those observations written will be read back in later in the data step and when they are directories it will lead to more observations being added.&lt;/P&gt;</description>
    <pubDate>Sat, 06 Feb 2021 18:04:22 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-02-06T18:04:22Z</dc:date>
    <item>
      <title>How Can MODIFY and REPLACE Read Filenames Recursively?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-Can-MODIFY-and-REPLACE-Read-Filenames-Recursively/m-p/717312#M221803</link>
      <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-List-all-the-files-in-a-folder/m-p/674066#M202919" target="_blank"&gt;Re: Need alternative of "Filename" statement with Pipe operator for SAS University Edition&lt;/A&gt; and &lt;A href="https://communities.sas.com/t5/SAS-Analytics-U/Bulk-Download-all-my-files-from-SAS-Ondemand/m-p/713063#M9955" target="_blank"&gt;Re: Bulk Download all my files from SAS Ondemand&lt;/A&gt; introduce the way to read filenames recursively via &lt;CODE&gt;modify&lt;/CODE&gt;, &lt;CODE&gt;replace&lt;/CODE&gt;, and &lt;CODE&gt;dread&lt;/CODE&gt; without &lt;CODE&gt;pipe&lt;/CODE&gt;.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data i;
    length i j $800;
    i='!USERPROFILE\Desktop';
run;

data i;
    modify i;
    a=filename("i",catx("\",i,j));
    a=dopen("i");
    if a then do;
        i=catx("\",i,j);
        j="";
    end;
    replace;
    if a;
    do k=1 to dnum(a);
        j=dread(a,k);
        output;
    end;
    a=dclose(a);
    a=filename("i");
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Usually, I use neither &lt;CODE&gt;modify&lt;/CODE&gt; nor &lt;CODE&gt;replace&lt;/CODE&gt;, but why can the code above read filenames recursively while the code below cannot?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data i;
    length i j $800;
    i='!USERPROFILE\Desktop';
    a=filename("i",catx("\",i,j));
    a=dopen("i");
    if a then do;
        i=catx("\",i,j);
        j="";
    end;
    if a;
    do k=1 to dnum(a);
        j=dread(a,k);
        output;
    end;
    a=dclose(a);
    a=filename("i");
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I wonder whether the two separate &lt;CODE&gt;data&lt;/CODE&gt; steps are necessary.&lt;/P&gt;</description>
      <pubDate>Sat, 06 Feb 2021 15:46:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-Can-MODIFY-and-REPLACE-Read-Filenames-Recursively/m-p/717312#M221803</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2021-02-06T15:46:32Z</dc:date>
    </item>
    <item>
      <title>Re: How Can MODIFY and REPLACE Read Filenames Recursively?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-Can-MODIFY-and-REPLACE-Read-Filenames-Recursively/m-p/717316#M221806</link>
      <description>probably you need to control the data step loop /iteration, more. With MODIFYstatement, the rules are different from the DATA step without. The second version (one data step) will stop an the end of the first iteration.</description>
      <pubDate>Sat, 06 Feb 2021 18:00:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-Can-MODIFY-and-REPLACE-Read-Filenames-Recursively/m-p/717316#M221806</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2021-02-06T18:00:22Z</dc:date>
    </item>
    <item>
      <title>Re: How Can MODIFY and REPLACE Read Filenames Recursively?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-Can-MODIFY-and-REPLACE-Read-Filenames-Recursively/m-p/717317#M221807</link>
      <description>&lt;P&gt;It is not really "recursive" in the classical meaning of that term.&amp;nbsp; What is is doing to appending records to the end of the dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A normal data step will stop when it reads past the end of the input dataset (or input file when using INPUT statement).&amp;nbsp; In this step since you are modifying the input dataset instead of writing to a new dataset the OUTPUT statements are causing extra observations to added to the input dataset.&amp;nbsp; So those observations written will be read back in later in the data step and when they are directories it will lead to more observations being added.&lt;/P&gt;</description>
      <pubDate>Sat, 06 Feb 2021 18:04:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-Can-MODIFY-and-REPLACE-Read-Filenames-Recursively/m-p/717317#M221807</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-02-06T18:04:22Z</dc:date>
    </item>
  </channel>
</rss>

