<?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: Reading contents of a directory in SAS Studio using Filename and PIPE in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/Reading-contents-of-a-directory-in-SAS-Studio-using-Filename-and/m-p/974740#M11470</link>
    <description>&lt;P&gt;You a missing the period that would change the meaning of the INPUT statement.&lt;/P&gt;
&lt;P&gt;What you ran:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input study $ 1000 ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which makes STUDY as a one byte character variable and populates it with the 1,000th&amp;nbsp; byte on the line.&lt;/P&gt;
&lt;P&gt;What you wanted:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input study $1000. ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which will make STUDY as a 1,000 byte character variable and populate it with the left aligned value of the first 1,000 bytes from the line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That is a very common typo.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you appear to want the whole line you could also just use the _INFILE_ automatic variable instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tmp;
   infile fref truncover;
   length study $1000 ;
   input;
   study = _infile_;
   dir="&amp;amp;sharedrive\Projects";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you did need the leading spaces removed as your original code was doing you could use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;study = left(_infile_) ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 10 Sep 2025 13:57:27 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2025-09-10T13:57:27Z</dc:date>
    <item>
      <title>Reading contents of a directory in SAS Studio using Filename and PIPE</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Reading-contents-of-a-directory-in-SAS-Studio-using-Filename-and/m-p/974709#M11468</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Im using a code that helps read the contents of a particular directory, as below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let filepath = "&amp;amp;sharedrive\Projects";&lt;/P&gt;&lt;P&gt;filename fref PIPE %sysfunc(quote(dir &amp;amp;filepath /AD /b)) lrecl=32767;&lt;/P&gt;&lt;P&gt;data tmp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;infile fref truncover;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;input study $1000;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;dir="&amp;amp;sharedrive\Projects";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On running the code, there is no error and I also get the correct number of records [there were 105 subfolders in Projects directory and the dataset TMP also had 105 records). But for some reason the STUDY variable is blank instead of having the names of the subfolders. [Please note that the "sharedrive" macro variable resolves correctly based on my setup.sas file that I call in the main program].&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;Kally&lt;/P&gt;</description>
      <pubDate>Wed, 10 Sep 2025 06:33:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Reading-contents-of-a-directory-in-SAS-Studio-using-Filename-and/m-p/974709#M11468</guid>
      <dc:creator>Kally80</dc:creator>
      <dc:date>2025-09-10T06:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: Reading contents of a directory in SAS Studio using Filename and PIPE</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Reading-contents-of-a-directory-in-SAS-Studio-using-Filename-and/m-p/974739#M11469</link>
      <description>&lt;P&gt;There are many ways to input data, one way to fix this is by using formatted input:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   input study $1000.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Sep 2025 13:39:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Reading-contents-of-a-directory-in-SAS-Studio-using-Filename-and/m-p/974739#M11469</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2025-09-10T13:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: Reading contents of a directory in SAS Studio using Filename and PIPE</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Reading-contents-of-a-directory-in-SAS-Studio-using-Filename-and/m-p/974740#M11470</link>
      <description>&lt;P&gt;You a missing the period that would change the meaning of the INPUT statement.&lt;/P&gt;
&lt;P&gt;What you ran:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input study $ 1000 ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which makes STUDY as a one byte character variable and populates it with the 1,000th&amp;nbsp; byte on the line.&lt;/P&gt;
&lt;P&gt;What you wanted:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input study $1000. ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which will make STUDY as a 1,000 byte character variable and populate it with the left aligned value of the first 1,000 bytes from the line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That is a very common typo.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you appear to want the whole line you could also just use the _INFILE_ automatic variable instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tmp;
   infile fref truncover;
   length study $1000 ;
   input;
   study = _infile_;
   dir="&amp;amp;sharedrive\Projects";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you did need the leading spaces removed as your original code was doing you could use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;study = left(_infile_) ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Sep 2025 13:57:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Reading-contents-of-a-directory-in-SAS-Studio-using-Filename-and/m-p/974740#M11470</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-09-10T13:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: Reading contents of a directory in SAS Studio using Filename and PIPE</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Reading-contents-of-a-directory-in-SAS-Studio-using-Filename-and/m-p/974981#M11471</link>
      <description>&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your response. I too realized the issue quite late. Infact what I have done is that I introduced a length statement [like how you mentioned] and got the code working fine.&lt;/P&gt;&lt;P&gt;Thanks again for taking the time to get back.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Kailly&lt;/P&gt;</description>
      <pubDate>Sat, 13 Sep 2025 06:29:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Reading-contents-of-a-directory-in-SAS-Studio-using-Filename-and/m-p/974981#M11471</guid>
      <dc:creator>Kally80</dc:creator>
      <dc:date>2025-09-13T06:29:14Z</dc:date>
    </item>
  </channel>
</rss>

