<?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: loop import csv file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/loop-import-csv-file/m-p/832785#M329193</link>
    <description>&lt;P&gt;A %DO must be part of a macro, you cannot use it in "open code".&lt;/P&gt;
&lt;P&gt;If the csv files (which are NOT Excel files) have the same structure, you can read them in one DATA step.&lt;/P&gt;</description>
    <pubDate>Sun, 11 Sep 2022 21:53:28 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-09-11T21:53:28Z</dc:date>
    <item>
      <title>loop import csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loop-import-csv-file/m-p/832783#M329192</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a number of excel files named as file_a, file_b&amp;nbsp; until file_h.&amp;nbsp; I'd like to use a macro do loop to import the files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Following the code in this&lt;A href="https://blogs.sas.com/content/sastraining/2015/01/30/sas-authors-tip-getting-the-macro-language-to-perform-a-do-loop-over-a-list-of-values/" target="_self"&gt; link&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I write the following code.&amp;nbsp; I also tried to add % before proc import command and it does not work either.&amp;nbsp; That would be great if someone can help here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%let list = a b c d e f g h;
%local i next_name;
%let i=1;
%do %while (%scan(&amp;amp;list, &amp;amp;i) ne );
   %let next_name = %scan(&amp;amp;list, &amp;amp;i);
 proc import out=jobpost&amp;amp;next_name
	datafile="H:\bdata\file_&amp;amp;next_name..csv"
	dbms='' replace;
	run;
   %let i = %eval(&amp;amp;i + 1);
%end;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 11 Sep 2022 21:31:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loop-import-csv-file/m-p/832783#M329192</guid>
      <dc:creator>daradanye</dc:creator>
      <dc:date>2022-09-11T21:31:53Z</dc:date>
    </item>
    <item>
      <title>Re: loop import csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loop-import-csv-file/m-p/832785#M329193</link>
      <description>&lt;P&gt;A %DO must be part of a macro, you cannot use it in "open code".&lt;/P&gt;
&lt;P&gt;If the csv files (which are NOT Excel files) have the same structure, you can read them in one DATA step.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Sep 2022 21:53:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loop-import-csv-file/m-p/832785#M329193</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-09-11T21:53:28Z</dc:date>
    </item>
  </channel>
</rss>

