<?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 Excel files into one SAS file in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files-into-one-SAS-file/m-p/675864#M36688</link>
    <description>&lt;P&gt;If you would not use the Excel file format, but textual data instead (like CSV files), it would require just a single data step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
length fname infile_name $200;
retain infile_name;
infile "/path/*.csv" dlm=',' dsd filename=fname;
if fname ne infile_name
then do;
  input; /* skips header line of csv */
  infile_name = fname;
end;
input
  /* add your variable inputs here */
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that textual data is always better to work with than Excel files. ALWAYS.&lt;/P&gt;</description>
    <pubDate>Tue, 11 Aug 2020 09:46:28 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-08-11T09:46:28Z</dc:date>
    <item>
      <title>Importing multiple Excel files into one SAS file</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files-into-one-SAS-file/m-p/675846#M36683</link>
      <description>&lt;P&gt;Hi all,&lt;BR /&gt;&lt;BR /&gt;I have 5 Excel files, each of the file contains 5 sheets, each sheet contains around 50 rows. So this means 1 file has in total 50 x 5 = 250 rows. Is there a speedy trick I can use to combine all these 5 files (including sheets) into 1 SAS file with in total 250 x 5 rows = 12.500 rows?&lt;BR /&gt;&lt;BR /&gt;Please note I'm using SAS EG 7.15. Appreciate your help all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2020 08:53:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files-into-one-SAS-file/m-p/675846#M36683</guid>
      <dc:creator>AK100</dc:creator>
      <dc:date>2020-08-11T08:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple Excel files into one SAS file</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files-into-one-SAS-file/m-p/675852#M36684</link>
      <description>&lt;P&gt;To concatenate all sheets in one swoop, you will have to assign libnames to all Excel files and then derive the sheet names from sashelp.vtable.&lt;/P&gt;
&lt;P&gt;How you can automate the libnames depends on the path and file names of the Excel files.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2020 09:10:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files-into-one-SAS-file/m-p/675852#M36684</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-08-11T09:10:31Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple Excel files into one SAS file</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files-into-one-SAS-file/m-p/675853#M36685</link>
      <description>Hi Kurt, that was a long time. &lt;BR /&gt;&lt;BR /&gt;I don't really understand what you mean...all the files are in 1 folder on my desktop.</description>
      <pubDate>Tue, 11 Aug 2020 09:15:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files-into-one-SAS-file/m-p/675853#M36685</guid>
      <dc:creator>AK100</dc:creator>
      <dc:date>2020-08-11T09:15:14Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple Excel files into one SAS file</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files-into-one-SAS-file/m-p/675860#M36686</link>
      <description>&lt;P&gt;There are two ways to read Excel files into SAS:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;PROC IMPORT - reads one sheet at a time&lt;/LI&gt;
&lt;LI&gt;LIBNAME XLSX - makes all sheets in a workbook available as pseudo-datasets in a single library&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Since all your files reside in one directory, the process would be (it is required that the SAS session has physical access to the directory, so this won't work with a remote server)&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;retrieve a listing of the directory (DOPEN, DREAD functions in a data step)&lt;/LI&gt;
&lt;LI&gt;use this dataset of filenames to dynamically create a series of libnames with a fixed prefix&lt;/LI&gt;
&lt;LI&gt;retrieve all MEMNAMEs from SASHELP.VTABLE, for entries where LIBNAME starts with the prefix, into a macro variable&lt;/LI&gt;
&lt;LI&gt;Use this in the SET statement of the data step that creates your wanted dataset&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;If your SAS session runs on a remote server, the Excel files must first be made available to it (copy to the server, or use a network resource shared on your desktop and the SAS server)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For more detailed help, you need to supply additional information regarding your SAS architecture and possible directory and file names.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2020 10:06:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files-into-one-SAS-file/m-p/675860#M36686</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-08-11T10:06:31Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple Excel files into one SAS file</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files-into-one-SAS-file/m-p/675862#M36687</link>
      <description>So the 2nd option applies for me, which sounds quiet complex... but okay thank you for your answer.</description>
      <pubDate>Tue, 11 Aug 2020 09:38:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files-into-one-SAS-file/m-p/675862#M36687</guid>
      <dc:creator>AK100</dc:creator>
      <dc:date>2020-08-11T09:38:58Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple Excel files into one SAS file</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files-into-one-SAS-file/m-p/675864#M36688</link>
      <description>&lt;P&gt;If you would not use the Excel file format, but textual data instead (like CSV files), it would require just a single data step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
length fname infile_name $200;
retain infile_name;
infile "/path/*.csv" dlm=',' dsd filename=fname;
if fname ne infile_name
then do;
  input; /* skips header line of csv */
  infile_name = fname;
end;
input
  /* add your variable inputs here */
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that textual data is always better to work with than Excel files. ALWAYS.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2020 09:46:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files-into-one-SAS-file/m-p/675864#M36688</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-08-11T09:46:28Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple Excel files into one SAS file</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files-into-one-SAS-file/m-p/675865#M36689</link>
      <description>&lt;P&gt;In theory combining the sheets is as easy as &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; explained it, but with real-world excel-files, things get interesting in 7 of 9 cases, because excel is hardly usable as file-format for data - this has been discussed so many time, i won't repeat it again. So, after you have assigned all libraries, you have to verify that each variable has the same type and length in all datasets/sheets.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2020 09:48:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files-into-one-SAS-file/m-p/675865#M36689</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-08-11T09:48:01Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple Excel files into one SAS file</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files-into-one-SAS-file/m-p/675907#M36690</link>
      <description>&lt;P&gt;Let me weigh in here on a couple of things. How you approach is up to you but there are a few things to point out. Kurt has mentioned 2 ways to read Excel but there are other ways as well. Excel is ODBC and OleDb capable so you can use the Access engines too. I don't know your environment so not sure what you have. Your Excel format is also just a zipped XML file so the XML engine can also be used. Additionally, you can read Excel using any of the libraries in other languages and push it to SAS (EPPlus, GemBox, Aspose, etc.) or, better yet, do all of the combination there and change the data storage means. There is also the dreaded VBA.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, look at using AbleBits to do this since it provides that capability plus loads more features.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IMO, CSV or textual storage is a very poor choice. Why? It lacks a type and the type has to be inferred in some way. Excel is bad since it lacks typing but SAS also has limited typing (chars/nums). If you change storage means, JSON, XML, DBMS all have better typing but the latter is more preferred.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have SAS Access to ODBC, consider using it. If you have Microsoft Access, consider importing the data there and then using ODBC.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lacking that, consider VBA in Excel or one of the SAS snippets here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2020 13:01:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files-into-one-SAS-file/m-p/675907#M36690</guid>
      <dc:creator>AlanC</dc:creator>
      <dc:date>2020-08-11T13:01:00Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple Excel files into one SAS file</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files-into-one-SAS-file/m-p/675918#M36691</link>
      <description>&lt;P&gt;Thank you all, sounds pretty complex all.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2020 14:20:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files-into-one-SAS-file/m-p/675918#M36691</guid>
      <dc:creator>AK100</dc:creator>
      <dc:date>2020-08-11T14:20:18Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple Excel files into one SAS file</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files-into-one-SAS-file/m-p/675923#M36692</link>
      <description>&lt;P&gt;Not at all. Try ODBC if you have it. Simple libname.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2020 14:35:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files-into-one-SAS-file/m-p/675923#M36692</guid>
      <dc:creator>AlanC</dc:creator>
      <dc:date>2020-08-11T14:35:46Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple Excel files into one SAS file</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files-into-one-SAS-file/m-p/675930#M36693</link>
      <description>&lt;P&gt;Here's one way. But what can often happen in these cases especially with PROC IMPORT is that the data is imported with different variable types or formats which makes it harder to combine them after the fact. You'll have to include a step where you check if each variable has the right type/format to combine them as well, especially if this needs to be an automatic process.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&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;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2020 15:41:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files-into-one-SAS-file/m-p/675930#M36693</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-08-11T15:41:42Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple Excel files into one SAS file</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files-into-one-SAS-file/m-p/676075#M36704</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13798"&gt;@AlanC&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Not at all. Try ODBC if you have it. Simple libname.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;But before that, you have to create a DSN for each Excel file, IIRC.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2020 06:32:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files-into-one-SAS-file/m-p/676075#M36704</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-08-12T06:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple Excel files into one SAS file</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files-into-one-SAS-file/m-p/676077#M36705</link>
      <description>&lt;P&gt;You won't use text files for working storage, but for data transfer needs and long-time preservation they are the best option, by lightyears.&lt;/P&gt;
&lt;P&gt;A text file is a text file is a text file, and has been so for five decades (introduction of ASCII), with little to no disruptions (the most recent one being UTF). I can inspect text files with the most simple tools (vi on UNIX), and because of no in-built proprietary type or structure information, they give control to the receiving software system and its users. I actually consider this lack of forced typing one of the most important &lt;EM&gt;positive&lt;/EM&gt; features of text files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2020 06:44:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files-into-one-SAS-file/m-p/676077#M36705</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-08-12T06:44:07Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple Excel files into one SAS file</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files-into-one-SAS-file/m-p/676080#M36706</link>
      <description>&lt;P&gt;Kurt,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I had no issue with the approaches you suggested merely that there were more than 2 ways to handle. I can easily envision a dozen but the complexity, to a SAS user, varies. As far as DSN is concerned, use the noprompt option and specify it in a string with a macro loop if desired. That eliminates the DSN requirement. I use noprompt primarily with SQL Server so let me know of any issues with Excel.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My other issue, in the thread, was with text files as a good choice. Yes, agree on ease of use but is this a number or string: 'ABC123'? Without more info, you can't be sure. That is a problem.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2020 07:14:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files-into-one-SAS-file/m-p/676080#M36706</guid>
      <dc:creator>AlanC</dc:creator>
      <dc:date>2020-08-12T07:14:09Z</dc:date>
    </item>
  </channel>
</rss>

