<?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: need to create a macro to mport multiple .csv files based on user inputs in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/need-to-create-a-macro-to-mport-multiple-csv-files-based-on-user/m-p/347761#M63648</link>
    <description>&lt;P&gt;Are your file names actually going to match&amp;nbsp;&amp;nbsp;"&amp;amp;next_retailer"? As in does that macro variable have the file extention such as .csv? You may need, at a minimum, &amp;nbsp;"&amp;amp;next_retailer..csv" and the two . are needed. The first one tells the macro compilier it is the end of the name of the macro variable the second is part of the actual file name.&lt;/P&gt;
&lt;P&gt;And it really is a good idea to have the complete path as well as I'm not sure that you will get the correct "current folder".&lt;/P&gt;</description>
    <pubDate>Thu, 06 Apr 2017 14:51:29 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-04-06T14:51:29Z</dc:date>
    <item>
      <title>need to create a macro to mport multiple .csv files based on user inputs</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/need-to-create-a-macro-to-mport-multiple-csv-files-based-on-user/m-p/347625#M63634</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to write a SAS macro that will import multiple .csv files present in the current folder as per the user inputs given. Here is what i have written so far but it is throwing exit 2. I am running SAS9. on unix. In the below example, Meijer and publix will be user provided details. I want to write a macro that will import files titled Meijer and publix from current folder and create data sets of the same name. This list i.e retailers can vary everytime users run this code. I am currently getting exit 2 which says too few arguements for %scan function. Please advise.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let retailers= Meijer publix;&lt;/P&gt;&lt;P&gt;%macro next_ret;&lt;BR /&gt;%let i=1;&lt;BR /&gt;%do %while (%scan(&amp;amp;retailers &amp;amp;i) ne );&lt;BR /&gt;%let next_retailer = %scan(&amp;amp;retailers &amp;amp;i);&lt;/P&gt;&lt;P&gt;proc import datafile = "&amp;amp;next_retailer" out=&amp;amp;next_retailer_stores dbms=csv replace;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%let i = %eval(&amp;amp;i + 1);&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;%next_ret;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Pawan&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 08:26:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/need-to-create-a-macro-to-mport-multiple-csv-files-based-on-user/m-p/347625#M63634</guid>
      <dc:creator>tolapa</dc:creator>
      <dc:date>2017-04-06T08:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: need to create a macro to mport multiple .csv files based on user inputs</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/need-to-create-a-macro-to-mport-multiple-csv-files-based-on-user/m-p/347632#M63635</link>
      <description>&lt;P&gt;Am going to suggest a far out there idea here, I put "import multiple csv" into the search area at the top, and there was about 100 topics suggesting many different ways of doing it /sarcasm&amp;nbsp;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To note, you don't need macro - you never&amp;nbsp;&lt;STRONG&gt;need&lt;/STRONG&gt; macro.&lt;/P&gt;
&lt;P&gt;Also, I would avoid using proc import - this is guessing procedure so you don't really know what your going to get out. &amp;nbsp;Write a datastep and code in exactly what each column should be, what it looks like, and how to read it. &amp;nbsp;I.e. you take 100% full control over your data.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 09:08:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/need-to-create-a-macro-to-mport-multiple-csv-files-based-on-user/m-p/347632#M63635</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-04-06T09:08:55Z</dc:date>
    </item>
    <item>
      <title>Re: need to create a macro to mport multiple .csv files based on user inputs</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/need-to-create-a-macro-to-mport-multiple-csv-files-based-on-user/m-p/347667#M63640</link>
      <description>&lt;P&gt;hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Arguments for SAS macro functions are separated with a comma, your scan expression should look like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%scan(&amp;amp;retailers, &amp;amp;i)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bruno&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 11:55:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/need-to-create-a-macro-to-mport-multiple-csv-files-based-on-user/m-p/347667#M63640</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2017-04-06T11:55:20Z</dc:date>
    </item>
    <item>
      <title>Re: need to create a macro to mport multiple .csv files based on user inputs</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/need-to-create-a-macro-to-mport-multiple-csv-files-based-on-user/m-p/347704#M63644</link>
      <description>&lt;P&gt;Check SAS 9.4 macro appendix documentation for examples of looping through variables and several other useful examples.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 13:31:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/need-to-create-a-macro-to-mport-multiple-csv-files-based-on-user/m-p/347704#M63644</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-06T13:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: need to create a macro to mport multiple .csv files based on user inputs</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/need-to-create-a-macro-to-mport-multiple-csv-files-based-on-user/m-p/347761#M63648</link>
      <description>&lt;P&gt;Are your file names actually going to match&amp;nbsp;&amp;nbsp;"&amp;amp;next_retailer"? As in does that macro variable have the file extention such as .csv? You may need, at a minimum, &amp;nbsp;"&amp;amp;next_retailer..csv" and the two . are needed. The first one tells the macro compilier it is the end of the name of the macro variable the second is part of the actual file name.&lt;/P&gt;
&lt;P&gt;And it really is a good idea to have the complete path as well as I'm not sure that you will get the correct "current folder".&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 14:51:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/need-to-create-a-macro-to-mport-multiple-csv-files-based-on-user/m-p/347761#M63648</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-06T14:51:29Z</dc:date>
    </item>
  </channel>
</rss>

