<?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: Using DI Studio to read multiple CSV files in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Using-DI-Studio-to-read-multiple-CSV-files/m-p/332084#M9784</link>
    <description>Short version of &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt; answer: your second option is definitely the prime choice. &lt;BR /&gt;An alternative if you want to avoid the complexity of inner/outer job loops is to use an aggregate file location. This would be simpler DIS wise but makes a bit harder to add log/audit functionality.&lt;BR /&gt;Either way, you may to take into account functionality to not read a file twice (look up audit table or physically move the file after reading).</description>
    <pubDate>Mon, 13 Feb 2017 07:03:39 GMT</pubDate>
    <dc:creator>LinusH</dc:creator>
    <dc:date>2017-02-13T07:03:39Z</dc:date>
    <item>
      <title>Using DI Studio to read multiple CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Using-DI-Studio-to-read-multiple-CSV-files/m-p/331756#M9774</link>
      <description>&lt;P&gt;Please help, I'm somewhat skilled with DI Studio - but not necessarily with SAS programming. I need some good details on how to read multiple CSV files into a SAS table using DI Studio.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The files will all have the same fields - but the filenames will vary. For example the filenames could be "Detail_12345.csv, Detail_45678.csv, and Detail_98765.csv&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been reading that I should create user written code to read in the files at once. Another suggestion was to create an iterative job to pass the filename to the main job that read&amp;nbsp;each file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What do you suggest I do - and what are the specific transformations I should utilize?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you!&lt;/P&gt;</description>
      <pubDate>Sat, 11 Feb 2017 00:52:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Using-DI-Studio-to-read-multiple-CSV-files/m-p/331756#M9774</guid>
      <dc:creator>kjarvis</dc:creator>
      <dc:date>2017-02-11T00:52:16Z</dc:date>
    </item>
    <item>
      <title>Re: Using DI Studio to read multiple CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Using-DI-Studio-to-read-multiple-CSV-files/m-p/331925#M9777</link>
      <description>&lt;P&gt;To use DIS efficiently you need to get to an at least intermediate SAS coding level (Base SAS, SQL and macro language).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without the coding skills debugging (reading logs) will be difficult and you'll also be challenged to implement not only logically correct but also performant processes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As for your question:&lt;/P&gt;
&lt;P&gt;If your .csv's all have the same structure and don't have a header row with column names then you could use a wildcard: &lt;EM&gt;Detail_*.csv&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Create a job with an external file metadata object for one of the .csv's, a File Reader and a target SAS table and test if this works. Once tested change the name of the external file in the external file metadata to the asterix syntax (the &lt;EM&gt;wildcard&lt;/EM&gt; name).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Should your .csv's have a header row then things become a bit more involved and you need to give as as much detail as you can (i.e. how the folder where the .csv's are looks like - read everything in it or just files following a naming pattern, how often do you need to run the process, is this about a fully productionworthy implementation, etc. ).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One way to go would be to first create a listing of .csv names (user written code), load these names into a temporary SAS Work table and then use this work tables as control table for a loop transformation. Inside the loop transformation (the inner job) is external table metadata (this time with a macro variable in double quotes as file name - the parameter passed to the inner job, a file reader and an append node which collects all the data read via the iterations through the inner job).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you've got header rows then there is eventually also a "hack" option which still would allow you to use the simple wildcard approach - but it's something I would first need to test myself before I can propose it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suggest that as a first step you implement a DIS job which reads a single .csv into your target table and we go from there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Feb 2017 04:25:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Using-DI-Studio-to-read-multiple-CSV-files/m-p/331925#M9777</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-02-12T04:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: Using DI Studio to read multiple CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Using-DI-Studio-to-read-multiple-CSV-files/m-p/332084#M9784</link>
      <description>Short version of &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt; answer: your second option is definitely the prime choice. &lt;BR /&gt;An alternative if you want to avoid the complexity of inner/outer job loops is to use an aggregate file location. This would be simpler DIS wise but makes a bit harder to add log/audit functionality.&lt;BR /&gt;Either way, you may to take into account functionality to not read a file twice (look up audit table or physically move the file after reading).</description>
      <pubDate>Mon, 13 Feb 2017 07:03:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Using-DI-Studio-to-read-multiple-CSV-files/m-p/332084#M9784</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2017-02-13T07:03:39Z</dc:date>
    </item>
  </channel>
</rss>

