<?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: Importing multiple CSV files in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-CSV-files/m-p/668450#M200376</link>
    <description>I still keep getting the same warning even after changing the code.</description>
    <pubDate>Fri, 10 Jul 2020 19:09:36 GMT</pubDate>
    <dc:creator>DivyaGadde</dc:creator>
    <dc:date>2020-07-10T19:09:36Z</dc:date>
    <item>
      <title>Importing multiple CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-CSV-files/m-p/666451#M199405</link>
      <description>&lt;P&gt;I have used the search function to look at other posts but am struggling to find an answer to my problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to import all CSV files that exist within a directory using the code found here:&amp;nbsp;&lt;A href="https://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=n0ctmldxf23ixtn1kqsoh5bsgmg8.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en"&gt;https://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=n0ctmldxf23ixtn1kqsoh5bsgmg8.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class="xisDoc-code"&gt;&lt;CODE&gt;%macro drive(dir,ext); 
   %local cnt filrf rc did memcnt name; 
   %let cnt=0;          

   %let filrf=mydir;    
   %let rc=%sysfunc(filename(filrf,&amp;amp;dir)); 
   %let did=%sysfunc(dopen(&amp;amp;filrf));
    %if &amp;amp;did ne 0 %then %do;   
   %let memcnt=%sysfunc(dnum(&amp;amp;did));    

    %do i=1 %to &amp;amp;memcnt;              
                       
      %let name=%qscan(%qsysfunc(dread(&amp;amp;did,&amp;amp;i)),-1,.);                    
                    
      %if %qupcase(%qsysfunc(dread(&amp;amp;did,&amp;amp;i))) ne %qupcase(&amp;amp;name) %then %do;
       %if %superq(ext) = %superq(&amp;amp;name) %then %do;                         
          %let cnt=%eval(&amp;amp;cnt+1);       
          %put %qsysfunc(dread(&amp;amp;did,&amp;amp;i));  
          proc import datafile="&amp;amp;dir\%qsysfunc(dread(&amp;amp;did,&amp;amp;i))" out=dsn&amp;amp;cnt 
           dbms=csv replace;            
          run;          
       %end; 
      %end;  

    %end;
      %end;
  %else %put &amp;amp;dir cannot be open.;
  %let rc=%sysfunc(dclose(&amp;amp;did));      
             
 %mend drive;
 
%drive(c:\temp,csv) &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I am getting the following error message and cannot figure out where I'm going wrong:&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;WARNING: Apparent symbolic reference CSV not resolved.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The only part of the code I am updating is &lt;STRONG&gt;%drive(c:\temp, csv)&lt;/STRONG&gt; to change c:\temp to my directory location where the csv files are located.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All the CSV files have the same 5 variables and are in the same format. I am relatively new to SAS, but am hoping to utilize a macro as I have multiple CSV files to combine for several projects. Thank you in advance and please let me know if I can provide additional information.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2020 19:25:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-CSV-files/m-p/666451#M199405</guid>
      <dc:creator>ngallagher98146</dc:creator>
      <dc:date>2020-07-01T19:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-CSV-files/m-p/666466#M199411</link>
      <description>&lt;PRE class="xisDoc-code"&gt;&lt;CODE&gt; %if %superq(ext) = %superq(&amp;amp;name) %then %do; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;should be&lt;/P&gt;
&lt;PRE class="xisDoc-code"&gt;&lt;CODE&gt; %if %superq(&amp;amp;ext) = %superq(&amp;amp;name) %then %do; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2020 19:52:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-CSV-files/m-p/666466#M199411</guid>
      <dc:creator>smantha</dc:creator>
      <dc:date>2020-07-01T19:52:37Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-CSV-files/m-p/666469#M199413</link>
      <description>Thank you! This fixed the issue.</description>
      <pubDate>Wed, 01 Jul 2020 20:00:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-CSV-files/m-p/666469#M199413</guid>
      <dc:creator>ngallagher98146</dc:creator>
      <dc:date>2020-07-01T20:00:27Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-CSV-files/m-p/666541#M199448</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/214340"&gt;@smantha&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE class="xisDoc-code"&gt;&lt;CODE&gt; %if %superq(ext) = %superq(&amp;amp;name) %then %do; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;should be&lt;/P&gt;
&lt;PRE class="xisDoc-code"&gt;&lt;CODE&gt; %if %superq(&amp;amp;ext) = %superq(&amp;amp;name) %then %do; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That looks backwards.&amp;nbsp; The second form is saying that both the EXT and NAME macro variables contain the NAME of the macro variables to be evaluated and macro quoted.&amp;nbsp; From a quick scan of the code it looks to me like EXT and NAME instead have the actual values that you want macro quote.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %superq(ext) = %superq(name) %then %do; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Although the second call to %SUPERQ() is not needed since we know that the value of NAME is already macro quoted since it was created with the %QSCAN() macro function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %superq(ext) = &amp;amp;name %then %do; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jul 2020 04:27:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-CSV-files/m-p/666541#M199448</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-07-02T04:27:09Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-CSV-files/m-p/668450#M200376</link>
      <description>I still keep getting the same warning even after changing the code.</description>
      <pubDate>Fri, 10 Jul 2020 19:09:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-CSV-files/m-p/668450#M200376</guid>
      <dc:creator>DivyaGadde</dc:creator>
      <dc:date>2020-07-10T19:09:36Z</dc:date>
    </item>
  </channel>
</rss>

