<?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: List files in folder (CSV files) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/List-files-in-folder-CSV-files/m-p/743192#M232613</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;here you can go just updating the path in macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;CODE class=" language-sas"&gt;%LET PATH=;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET PATH=;

DATA filenames;
 RC=FILENAME("FILEREF","&amp;amp;PATH.");
 MYDIR=DOPEN("FILEREF");
 IF MYDIR &amp;gt; 0 THEN 
    NUM=DNUM(MYDIR);
	 DO I=1 TO NUM;
			IF I &amp;gt; 0 THEN DO
			   FILERE2=DREAD(MYDIR,i);
			   OUTPUT;
	END;
	END;
rc=dclose(mydir);
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 23 May 2021 05:55:59 GMT</pubDate>
    <dc:creator>singhsahab</dc:creator>
    <dc:date>2021-05-23T05:55:59Z</dc:date>
    <item>
      <title>List files in folder (CSV files)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/List-files-in-folder-CSV-files/m-p/743191#M232612</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to create a data set with one column with names of files exists in a folder.&lt;/P&gt;
&lt;P&gt;I run this code and get error.&lt;/P&gt;
&lt;P&gt;NOTE: Argument 1 to function DNUM(0) at line 158 column 13 is invalid.&lt;BR /&gt;ERROR: Invalid DO loop control information, either the INITIAL or TO expression is missing or the BY expression is missing, zero, &lt;BR /&gt;or invalid.&lt;BR /&gt;fref=#LN00027 fname= did=0 i=1 _ERROR_=1 _N_=1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is a problem with&amp;nbsp; do statement (dnum(did)).&lt;/P&gt;
&lt;P&gt;Instead of&amp;nbsp;dnum(did)&amp;nbsp; I wrote 20 (just for example) and then I recieve a data set with column fname with 20 rows but all of them with null values .&lt;/P&gt;
&lt;P&gt;May anyone help please?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data filenames;
length fref $8 fname $200;
did = filename(fref,'\\path\');
/*creates a file reference for the directory */
did = dopen(fref);
/*opens the directory */
/*creates a handle -DOPEN*/
do i = 1 to dnum(did);
  fname = dread(did,i);
  output;
end;
/*loops over all (DNUM) entries in the directory*/
/*and  reads each (DREAD)*/
did = dclose(did);
did = filename(fref);
/*At the end, it deassigns the handle and the file reference*/
keep fname;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 23 May 2021 04:07:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/List-files-in-folder-CSV-files/m-p/743191#M232612</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-05-23T04:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: List files in folder (CSV files)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/List-files-in-folder-CSV-files/m-p/743192#M232613</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;here you can go just updating the path in macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;CODE class=" language-sas"&gt;%LET PATH=;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET PATH=;

DATA filenames;
 RC=FILENAME("FILEREF","&amp;amp;PATH.");
 MYDIR=DOPEN("FILEREF");
 IF MYDIR &amp;gt; 0 THEN 
    NUM=DNUM(MYDIR);
	 DO I=1 TO NUM;
			IF I &amp;gt; 0 THEN DO
			   FILERE2=DREAD(MYDIR,i);
			   OUTPUT;
	END;
	END;
rc=dclose(mydir);
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 23 May 2021 05:55:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/List-files-in-folder-CSV-files/m-p/743192#M232613</guid>
      <dc:creator>singhsahab</dc:creator>
      <dc:date>2021-05-23T05:55:59Z</dc:date>
    </item>
    <item>
      <title>Re: List files in folder (CSV files)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/List-files-in-folder-CSV-files/m-p/743193#M232614</link>
      <description>&lt;P&gt;did=0 means that the file cannot be found, or is not a directory.&lt;/P&gt;
&lt;P&gt;I suspect that your SAS session does not have access to the same shared network resource that you use from your desktop.&lt;/P&gt;</description>
      <pubDate>Sun, 23 May 2021 05:57:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/List-files-in-folder-CSV-files/m-p/743193#M232614</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-05-23T05:57:11Z</dc:date>
    </item>
  </channel>
</rss>

