<?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 problem of using macro to import multiple csv files in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/problem-of-using-macro-to-import-multiple-csv-files/m-p/86785#M24791</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;There are tens of csv files in folder D:\users\...\desktop\list. I need to import them into SAS.&lt;/P&gt;&lt;P&gt;For illustration purpose, I only take 2 files as the example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let country1=abudhabi;&lt;/P&gt;&lt;P&gt;%let country2=argentina;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro import;&lt;/P&gt;&lt;P&gt;%do i =1 % to 2;&lt;/P&gt;&lt;P&gt;proc import out = &amp;amp;&amp;amp;country&amp;amp;i&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datafile="D:\users\...\desktop\list\&amp;amp;&amp;amp;country&amp;amp;i.csv"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dbms=csv replace;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%end;;&lt;/P&gt;&lt;P&gt;%mend import;&lt;/P&gt;&lt;P&gt;%import;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But the codes did not work and the error messages are as below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*WARNING: Apparent symbolic reference D not resolved;&lt;/P&gt;&lt;P&gt;*WARNING: Apparent symbolic reference D not resolved;&lt;/P&gt;&lt;P&gt;*WARNING: Apparent symbolic reference COUNTRY1CSV not resolved;&lt;/P&gt;&lt;P&gt;*ERROR: Physical file does not exist,D:\Users\...\Desktop\list\&amp;amp;&amp;amp;country&amp;amp;i.csv;&lt;/P&gt;&lt;P&gt;*ERROR: Import unsuccessful. See SAS Log for details.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Can anyone advise me what the problem is and how to resovle it? Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 19 Jun 2012 05:19:50 GMT</pubDate>
    <dc:creator>comeon2012</dc:creator>
    <dc:date>2012-06-19T05:19:50Z</dc:date>
    <item>
      <title>problem of using macro to import multiple csv files</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/problem-of-using-macro-to-import-multiple-csv-files/m-p/86785#M24791</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;There are tens of csv files in folder D:\users\...\desktop\list. I need to import them into SAS.&lt;/P&gt;&lt;P&gt;For illustration purpose, I only take 2 files as the example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let country1=abudhabi;&lt;/P&gt;&lt;P&gt;%let country2=argentina;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro import;&lt;/P&gt;&lt;P&gt;%do i =1 % to 2;&lt;/P&gt;&lt;P&gt;proc import out = &amp;amp;&amp;amp;country&amp;amp;i&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datafile="D:\users\...\desktop\list\&amp;amp;&amp;amp;country&amp;amp;i.csv"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dbms=csv replace;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%end;;&lt;/P&gt;&lt;P&gt;%mend import;&lt;/P&gt;&lt;P&gt;%import;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But the codes did not work and the error messages are as below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*WARNING: Apparent symbolic reference D not resolved;&lt;/P&gt;&lt;P&gt;*WARNING: Apparent symbolic reference D not resolved;&lt;/P&gt;&lt;P&gt;*WARNING: Apparent symbolic reference COUNTRY1CSV not resolved;&lt;/P&gt;&lt;P&gt;*ERROR: Physical file does not exist,D:\Users\...\Desktop\list\&amp;amp;&amp;amp;country&amp;amp;i.csv;&lt;/P&gt;&lt;P&gt;*ERROR: Import unsuccessful. See SAS Log for details.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Can anyone advise me what the problem is and how to resovle it? Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Jun 2012 05:19:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/problem-of-using-macro-to-import-multiple-csv-files/m-p/86785#M24791</guid>
      <dc:creator>comeon2012</dc:creator>
      <dc:date>2012-06-19T05:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: problem of using macro to import multiple csv files</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/problem-of-using-macro-to-import-multiple-csv-files/m-p/86786#M24792</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;amp;&amp;amp;country&amp;amp;i.csv&amp;nbsp; will resolve to Country1csv for i=1. &amp;amp;&amp;amp; will resolve to &amp;amp; and &amp;amp;i will resolve to 1 in the first pass. &lt;/P&gt;&lt;P&gt;Macro facility will try to resolve &amp;amp;Country1csv macro variable reference which fails.&lt;/P&gt;&lt;P&gt;The single period following macro variable reference will act as a delimiter and won't be part of the resulting text. &lt;/P&gt;&lt;P&gt;You will need to insert another '.' (period) after &amp;amp;&amp;amp;country&amp;amp;i to delimit the value of macro variable from the the file extension.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Replace '&amp;amp;&amp;amp;country&amp;amp;i.csv' to '&amp;amp;&amp;amp;country&amp;amp;i..csv'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not sure about the warning 'WARNING: Apparent symbolic reference D not resolved;' I could not see where macro variable D is referenced in the code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Jun 2012 05:44:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/problem-of-using-macro-to-import-multiple-csv-files/m-p/86786#M24792</guid>
      <dc:creator>Alpay</dc:creator>
      <dc:date>2012-06-19T05:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: problem of using macro to import multiple csv files</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/problem-of-using-macro-to-import-multiple-csv-files/m-p/86787#M24793</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It still did not work when I add another period.&lt;/P&gt;&lt;P&gt;But after I accidentally added another two period, i.e,&amp;nbsp; '&amp;amp;&amp;amp;country&amp;amp;i&lt;STRONG&gt;...&lt;/STRONG&gt;csv', it worked although&amp;nbsp; 'WARNING: Apparent symbolic reference D not resolved' still appeared. Anyways, the csv file were imported to SAS. Thank you Alpay.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Jun 2012 06:02:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/problem-of-using-macro-to-import-multiple-csv-files/m-p/86787#M24793</guid>
      <dc:creator>comeon2012</dc:creator>
      <dc:date>2012-06-19T06:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: problem of using macro to import multiple csv files</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/problem-of-using-macro-to-import-multiple-csv-files/m-p/86788#M24794</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are right. I did not test it before I submitted above code. &lt;/P&gt;&lt;P&gt;First period acts as a delimiter for &amp;amp;i in the first pass.&lt;/P&gt;&lt;P&gt;Second period acts as a delimiter for &amp;amp;Country1 in the second pass.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;amp;&amp;amp;Country&amp;amp;i.csv -&amp;gt; Country1csv&lt;/P&gt;&lt;P&gt;&amp;amp;&amp;amp;Country&amp;amp;i..csv -&amp;gt; abudahbicsv&lt;/P&gt;&lt;P&gt;&amp;amp;&amp;amp;Country&amp;amp;i...csv -&amp;gt; abudhabi.csv&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Jun 2012 06:32:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/problem-of-using-macro-to-import-multiple-csv-files/m-p/86788#M24794</guid>
      <dc:creator>Alpay</dc:creator>
      <dc:date>2012-06-19T06:32:50Z</dc:date>
    </item>
  </channel>
</rss>

