<?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: Assigning array to macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Assigning-array-to-macro-variable/m-p/475721#M122349</link>
    <description>Thanks for the above. I keep, however, getting an note saying "In a call to the FOPEN routine, the fileref /vya/transport/default/vyarun/incoming1/ah_property.csv exceeds 8 characters, and&lt;BR /&gt;will be truncated."&lt;BR /&gt;Any idea why that may be?</description>
    <pubDate>Thu, 05 Jul 2018 16:17:01 GMT</pubDate>
    <dc:creator>MikeFranz</dc:creator>
    <dc:date>2018-07-05T16:17:01Z</dc:date>
    <item>
      <title>Assigning array to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assigning-array-to-macro-variable/m-p/475702#M122339</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;DATA _null_;
	array files [1] $20 ('property.csv' 'lease.csv');&lt;BR /&gt;        do i = 0  to 1;
	      length filein 8 fileid 8;&lt;BR /&gt;              filein = fopen("/transport/default/run/incoming/files[i]",'I',1,'B');&lt;BR /&gt;        end;
RUN;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to loop through multiple CSVs saved on the server and copy them across to another folder (this is just part of the code). The issue, however, is that the code in filein evaluates directly to /transport/default/run/incoming/files[0]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I force it to evaluate "files[0]" to 'property.csv' and "files[1]" to 'lease.csv'?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jul 2018 15:39:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assigning-array-to-macro-variable/m-p/475702#M122339</guid>
      <dc:creator>MikeFranz</dc:creator>
      <dc:date>2018-07-05T15:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning array to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assigning-array-to-macro-variable/m-p/475704#M122340</link>
      <description>&lt;P&gt;Arrays don't use index of 0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You probably need&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do i = 1  to 2;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also, you don't want the files[i] inside the quotes, you'd need to concatenate it with the previous text.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jul 2018 15:42:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assigning-array-to-macro-variable/m-p/475704#M122340</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-07-05T15:42:29Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning array to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assigning-array-to-macro-variable/m-p/475707#M122342</link>
      <description>&lt;P&gt;How about this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA _null_;
	array files [0:1] $20 ('property.csv' 'lease.csv');D
        do i = 0  to 1;
	      length filein 8 fileid 8;
              filein = fopen("/transport/default/run/incoming/files[i]",'I',1,'B');
        end;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Jul 2018 15:49:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assigning-array-to-macro-variable/m-p/475707#M122342</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-07-05T15:49:32Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning array to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assigning-array-to-macro-variable/m-p/475709#M122343</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/109914"&gt;@MikeFranz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;DATA _null_;
	array files [1] $20 ('property.csv' 'lease.csv');&lt;BR /&gt;        do i = 0  to 1;
	      length filein 8 fileid 8;&lt;BR /&gt;              filein = fopen("/transport/default/run/incoming/files[i]",'I',1,'B');&lt;BR /&gt;        end;
RUN;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to loop through multiple CSVs saved on the server and copy them across to another folder (this is just part of the code). The issue, however, is that the code in filein evaluates directly to /transport/default/run/incoming/files[0]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do I force it to evaluate "files[0]" to 'property.csv' and "files[1]" to 'lease.csv'?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Mike&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;SAS is written to match how humans think so by default arrays index from 1 and not zero.&amp;nbsp; You can specify the lower and upper bounds of an array dimensions index if you really want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But for this problem it is easier to just tell the DO loop itself what values of FILENAME you want to loop over and skip the array and indexing.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;length filename path fullname $200 ;
path='/transport/default/run/incoming';
do filename = 'property.csv','lease.csv';
  fullname = catx('/',path,filename);
  ...
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jul 2018 16:09:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assigning-array-to-macro-variable/m-p/475709#M122343</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-07-05T16:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning array to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assigning-array-to-macro-variable/m-p/475721#M122349</link>
      <description>Thanks for the above. I keep, however, getting an note saying "In a call to the FOPEN routine, the fileref /vya/transport/default/vyarun/incoming1/ah_property.csv exceeds 8 characters, and&lt;BR /&gt;will be truncated."&lt;BR /&gt;Any idea why that may be?</description>
      <pubDate>Thu, 05 Jul 2018 16:17:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assigning-array-to-macro-variable/m-p/475721#M122349</guid>
      <dc:creator>MikeFranz</dc:creator>
      <dc:date>2018-07-05T16:17:01Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning array to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assigning-array-to-macro-variable/m-p/475722#M122350</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/109914"&gt;@MikeFranz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thanks for the above. I keep, however, getting an note saying "In a call to the FOPEN routine, the fileref /vya/transport/default/vyarun/incoming1/ah_property.csv exceeds 8 characters, and&lt;BR /&gt;will be truncated."&lt;BR /&gt;Any idea why that may be?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Read the manual. There are actually many examples.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The FOPEN() function wants a fileref and nor a physical filename.&amp;nbsp; Look at the FILENAME() function if you want to define the fileref in your data step.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jul 2018 16:19:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assigning-array-to-macro-variable/m-p/475722#M122350</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-07-05T16:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning array to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assigning-array-to-macro-variable/m-p/475723#M122351</link>
      <description>&lt;P&gt;You can’t just put arrayName[i] in the string like that.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use CATX though to create the string.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also use FCOPY() to move files around.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Path1 = catx(“\”, path, filename[1]);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;RC = FCOPY(path1, path2);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jul 2018 16:19:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assigning-array-to-macro-variable/m-p/475723#M122351</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-05T16:19:26Z</dc:date>
    </item>
  </channel>
</rss>

