<?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 read file from unix directory in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-file-from-unix-directory/m-p/738951#M230570</link>
    <description>&lt;P&gt;You will have to read all filenames into a dataset, and sort that by name, then you can get the 27th with a POINT= option:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fnames;
length dref $8 fname $200;
rc = filename(dref,"/folders/myfolders");
did = dopen(dref);
if did
then do i = 1 to min(dnum(did),27);
  fname = dread(did,i);
  output;
end;
if i le 27 then putlog "Not enough files!";
keep fname;
run;

proc sort data=fnames;
by fname;
run;

data _null_;
pt = 27;
set fnames point=pt;
call symputx('myfile',fname);
stop;
run;

%put &amp;amp;myfile.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 04 May 2021 15:25:05 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-05-04T15:25:05Z</dc:date>
    <item>
      <title>how to read file from unix directory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-file-from-unix-directory/m-p/738894#M230546</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Help needed in below question:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A unix directory contains&amp;nbsp; 30 csv files . i want to read the 27th file csv.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 May 2021 13:20:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-file-from-unix-directory/m-p/738894#M230546</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2021-05-04T13:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: how to read file from unix directory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-file-from-unix-directory/m-p/738917#M230555</link>
      <description>&lt;P&gt;In a data step, open the directory (assign a file reference with the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/lefunctionsref/n15scht124hr4nn1g296cqg2kqfa.htm" target="_blank" rel="noopener"&gt;FILENAME&lt;/A&gt; function, then use that in a &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/lefunctionsref/n0hpa8p9kacbran1ndqiw3krwohq.htm" target="_blank" rel="noopener"&gt;DOPEN&lt;/A&gt; call).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now you can loop over the contents of the directory (&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/lefunctionsref/n1u8n0tue0ymkrn109xu8ya01kle.htm" target="_blank" rel="noopener"&gt;DREAD&lt;/A&gt;, up to the value returned by the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/lefunctionsref/p0m5yzvai5v9phn1gsdca9j6utzw.htm" target="_blank" rel="noopener"&gt;DNUM&lt;/A&gt; function), and assign the returned filename to a macro variable (&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/lefunctionsref/p1fa0ay5pzr9yun1mvqxv8ipzd4d.htm" target="_blank" rel="noopener"&gt;CALL SYMPUTX&lt;/A&gt;) when the counter hits 27.&lt;/P&gt;</description>
      <pubDate>Tue, 04 May 2021 14:40:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-file-from-unix-directory/m-p/738917#M230555</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-05-04T14:40:06Z</dc:date>
    </item>
    <item>
      <title>Re: how to read file from unix directory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-file-from-unix-directory/m-p/738926#M230559</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/327170"&gt;@Aexor&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Help needed in below question:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A unix directory contains&amp;nbsp; 30 csv files . i want to read the 27th file csv.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You need to provide a lot more detail about what you are doing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you just want to find the name of the 27th file?&amp;nbsp; How are you ordering the files to determine which is the 27th?&lt;/P&gt;
&lt;P&gt;Do you want to actually read the file once you have found its name?&amp;nbsp; Do you know the fields that are supposed to be in the CSV file?&amp;nbsp; Or will you have to use a tool such as PROC IMPORT to guess how to read the file into data?&lt;/P&gt;</description>
      <pubDate>Tue, 04 May 2021 14:58:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-file-from-unix-directory/m-p/738926#M230559</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-04T14:58:25Z</dc:date>
    </item>
    <item>
      <title>Re: how to read file from unix directory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-file-from-unix-directory/m-p/738934#M230562</link>
      <description>Hi Tom,&lt;BR /&gt;&lt;BR /&gt;Thanks for checking.&lt;BR /&gt;Yes the files are in sequential order a.txt, b.txt and so on .so I want to read the 27th file and filelds are same in all files e.g name,class,number</description>
      <pubDate>Tue, 04 May 2021 15:09:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-file-from-unix-directory/m-p/738934#M230562</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2021-05-04T15:09:33Z</dc:date>
    </item>
    <item>
      <title>Re: how to read file from unix directory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-file-from-unix-directory/m-p/738951#M230570</link>
      <description>&lt;P&gt;You will have to read all filenames into a dataset, and sort that by name, then you can get the 27th with a POINT= option:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fnames;
length dref $8 fname $200;
rc = filename(dref,"/folders/myfolders");
did = dopen(dref);
if did
then do i = 1 to min(dnum(did),27);
  fname = dread(did,i);
  output;
end;
if i le 27 then putlog "Not enough files!";
keep fname;
run;

proc sort data=fnames;
by fname;
run;

data _null_;
pt = 27;
set fnames point=pt;
call symputx('myfile',fname);
stop;
run;

%put &amp;amp;myfile.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 May 2021 15:25:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-file-from-unix-directory/m-p/738951#M230570</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-05-04T15:25:05Z</dc:date>
    </item>
  </channel>
</rss>

