<?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: How to import multiple csv files, but one by one as an input to the program. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/522044#M141677</link>
    <description>Your case can be done in more than one way. See the other example where I use exactly that methodology. The key is to make it the same. You can do it your way of course, but mine is also perfectly valid and works. &lt;BR /&gt;&lt;BR /&gt;1. Create a data set with the list of files (similar to getting each car make/model). &lt;BR /&gt;2. Import each one.&lt;BR /&gt;3. Combine if necessary, but I think you said you wanted them as separate data sets. &lt;BR /&gt;&lt;BR /&gt;Ultimately how you want to do it is your choice.</description>
    <pubDate>Mon, 17 Dec 2018 21:18:21 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-12-17T21:18:21Z</dc:date>
    <item>
      <title>How to import multiple csv files, but one by one as an input to the program.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/521471#M141494</link>
      <description>&lt;P&gt;I have a SAS program which accepts csv files as inputs one at a time. I have a folder which gets populated on a a daily basis. I need help in such a way that If there are 3 input files today in the folder, I need these files to be imported one by one , and the program should run thrice. I have checked the communities and only found to import all files one at a time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;Inputs folder&lt;/P&gt;&lt;P&gt;1) inputfile_3873847&lt;/P&gt;&lt;P&gt;2)inputfile_ag1434&lt;/P&gt;&lt;P&gt;3)inputfile_288248&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need the above input files to be imported to the program one at a time&amp;nbsp; and the program should run thrice.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Dec 2018 14:28:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/521471#M141494</guid>
      <dc:creator>sreevatsan1991</dc:creator>
      <dc:date>2018-12-14T14:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to import multiple csv files, but one by one as an input to the program.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/521472#M141495</link>
      <description>&lt;P&gt;What do you mean by "program"? A .sas file, or just some steps in a project?&lt;/P&gt;
&lt;P&gt;And how are the csv files created? If they are created by other programs run from a scheduler, have the scheduler run your program automatically.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Dec 2018 14:36:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/521472#M141495</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-12-14T14:36:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to import multiple csv files, but one by one as an input to the program.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/521474#M141496</link>
      <description>&lt;P&gt;Can you run PIPE commands? Do you also want to read files from sub-folder within a folder.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Check the links below, you may need to tweak as per your requirement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/kb/45/805.html" target="_blank"&gt;http://support.sas.com/kb/45/805.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/kb/41/880.html" target="_blank"&gt;http://support.sas.com/kb/41/880.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After reading the files names you can load the data into SAS using a datastep or proc import.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Dec 2018 14:40:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/521474#M141496</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-12-14T14:40:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to import multiple csv files, but one by one as an input to the program.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/521477#M141497</link>
      <description>&lt;P&gt;Something like:&lt;/P&gt;
&lt;PRE&gt;%macro imp (fname=,dsname=);
  data &amp;amp;dsname.;
    infile "...pathtofile.../&amp;amp;fname..csv" dlm=",";
    input...;
  run;
%mend imp;

%imp (fname=inputfile_3873847,dsname=want1);
%imp (fname=inputfile_ag1434,dsname=want2);
%imp (fname=inputfile_288248,dsname=want3);
&lt;/PRE&gt;
&lt;P&gt;Best I can suggest with the very little information provided.&amp;nbsp; Note this is only a start to the code, you need to add extra bits to the data step.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Dec 2018 14:43:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/521477#M141497</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-12-14T14:43:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to import multiple csv files, but one by one as an input to the program.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/521478#M141498</link>
      <description>The incoming files are from a different team and not by a program. They&lt;BR /&gt;manually put those files. The program is in Enterprise guide. Currently it&lt;BR /&gt;important the file by name. I am just trying to include a program to&lt;BR /&gt;automate the import process.&lt;BR /&gt;</description>
      <pubDate>Fri, 14 Dec 2018 14:48:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/521478#M141498</guid>
      <dc:creator>sreevatsan1991</dc:creator>
      <dc:date>2018-12-14T14:48:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to import multiple csv files, but one by one as an input to the program.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/521520#M141512</link>
      <description>&lt;P&gt;Try next code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro imp(dsout_prefix, inp_names);
     %let n = %sysfunc(countw(&amp;amp;inp_names));
     %do i=1 %to &amp;amp;n;
            /*   your code where
                  input =  %scan(&amp;amp;imp_names , &amp;amp;i);
                 output = &amp;amp;dsout_prefix&amp;amp;i;
           */
     %end;
%mend imp;

%imp(want, inputfile_3873847 inputfile_ag1434 inputfile_288248);

/* output should be:  wan1, want2, want3 datasets */&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Dec 2018 15:58:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/521520#M141512</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2018-12-14T15:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to import multiple csv files, but one by one as an input to the program.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/521535#M141522</link>
      <description>&lt;P&gt;The input files&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;inputfile_3873847 inputfile_ag1434 inputfile_288248&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;are just an example. the names going to be&amp;nbsp; keep on changing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to pick up the all the files in a folder and import them one by one as an input to the program.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Dec 2018 16:08:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/521535#M141522</guid>
      <dc:creator>sreevatsan1991</dc:creator>
      <dc:date>2018-12-14T16:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to import multiple csv files, but one by one as an input to the program.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/521543#M141523</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/231626"&gt;@sreevatsan1991&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The input files&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;inputfile_3873847 inputfile_ag1434 inputfile_288248&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;are just an example. the names going to be&amp;nbsp; keep on changing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to pick up the all the files in a folder and import them one by one as an input to the program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This involves several steps.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Find the list of files in the folder - see the links someone else posted above.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Create a program to import a file - PROC IMPORT or macro with data step that takes the filename/path&lt;/P&gt;
&lt;P&gt;3. Import each file - macro or PROC IMPORT I assume. Once you have the file names, you can pass that to your import step via CALL EXECUTE() or a macro loop. I highly recommend CALL EXECUTE().&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All the steps are here, links above explain how to do each step and CALL EXECUTE has a good example in the documentation.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Dec 2018 16:16:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/521543#M141523</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-14T16:16:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to import multiple csv files, but one by one as an input to the program.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/522025#M141672</link>
      <description>&lt;P&gt;Thanks all for your suggestions. It really helped me. Now am able to import all the csv files as SAS datasets. But how do i dynamically run the program for different csv files.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lets consider the same above example. I have an SAS program which runs with CSV file as input.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If have three input files, how do i make the SAS program to run thrice with three different inputs (Its not going to be three, it changes daily)?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 19:56:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/522025#M141672</guid>
      <dc:creator>sreevatsan1991</dc:creator>
      <dc:date>2018-12-17T19:56:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to import multiple csv files, but one by one as an input to the program.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/522033#M141673</link>
      <description>&lt;A href="https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md" target="_blank"&gt;https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Make it work for a base case and then you automate it.</description>
      <pubDate>Mon, 17 Dec 2018 20:32:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/522033#M141673</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-17T20:32:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to import multiple csv files, but one by one as an input to the program.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/522034#M141674</link>
      <description>Here's another example of how to import all XLSX files in a specified folder. &lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://github.com/statgeek/SAS-Tutorials/blob/master/Import_all_files_one_type" target="_blank"&gt;https://github.com/statgeek/SAS-Tutorials/blob/master/Import_all_files_one_type&lt;/A&gt;</description>
      <pubDate>Mon, 17 Dec 2018 20:33:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/522034#M141674</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-17T20:33:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to import multiple csv files, but one by one as an input to the program.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/522041#M141676</link>
      <description>&lt;P&gt;I really appreciate&amp;nbsp; your quick response. In the given example the same procedure will be executed for different makes of car. But my case is different.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My current program runs by accepting a csv file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If there are 3 csv files in the folder, then the program should pick the first csv file and run completely. After this has been completed, then its should pick the second file and run completely.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In your example, you are getting list of makes of car as a string and passing one by one. In my case its not a string. I have to pass the whole dataset as an input to import.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 21:11:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/522041#M141676</guid>
      <dc:creator>sreevatsan1991</dc:creator>
      <dc:date>2018-12-17T21:11:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to import multiple csv files, but one by one as an input to the program.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/522044#M141677</link>
      <description>Your case can be done in more than one way. See the other example where I use exactly that methodology. The key is to make it the same. You can do it your way of course, but mine is also perfectly valid and works. &lt;BR /&gt;&lt;BR /&gt;1. Create a data set with the list of files (similar to getting each car make/model). &lt;BR /&gt;2. Import each one.&lt;BR /&gt;3. Combine if necessary, but I think you said you wanted them as separate data sets. &lt;BR /&gt;&lt;BR /&gt;Ultimately how you want to do it is your choice.</description>
      <pubDate>Mon, 17 Dec 2018 21:18:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/522044#M141677</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-17T21:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to import multiple csv files, but one by one as an input to the program.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/522049#M141679</link>
      <description>&lt;P&gt;Thanks so much for the response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your solution totally works for base program. But changing the current enterprise program into base is a tedious process.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But in the enterprise guide, i am stuck in automation&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1. Create a data set with the list of files (similar to getting each car make/model).&amp;nbsp; - Done&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Import each one. - Done&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But how to proceed after this approach in enterprise guide.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(in base we can just use an macro of the data-set&amp;nbsp;like &amp;amp;r_make in the procedure and data steps)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 22:31:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/522049#M141679</guid>
      <dc:creator>sreevatsan1991</dc:creator>
      <dc:date>2018-12-17T22:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to import multiple csv files, but one by one as an input to the program.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/522052#M141681</link>
      <description>You posted this in the Programming forum, not EG. I have no way of knowing you were using EG until now. If you're trying to automate this using GUI in EG that's a different question entirely than what I've answered here. Otherwise, they're all programs and not sure how they're different at all.</description>
      <pubDate>Mon, 17 Dec 2018 22:41:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-csv-files-but-one-by-one-as-an-input-to/m-p/522052#M141681</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-17T22:41:18Z</dc:date>
    </item>
  </channel>
</rss>

