<?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: Import one sheet from multiple excel files in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Import-one-sheet-from-multiple-excel-files/m-p/487028#M15181</link>
    <description>&lt;P&gt;RANGE is only for xls files and will not work if your files are xlsx. I suggest you use GETNAMES=NO with DATAROW=n (n- row where data starts). Once the file is imported then rename the column names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternate approach, convert the files to CSV or txt and then use data step to read the files.&lt;/P&gt;</description>
    <pubDate>Wed, 15 Aug 2018 15:13:04 GMT</pubDate>
    <dc:creator>SuryaKiran</dc:creator>
    <dc:date>2018-08-15T15:13:04Z</dc:date>
    <item>
      <title>Import one sheet from multiple excel files</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Import-one-sheet-from-multiple-excel-files/m-p/486807#M15165</link>
      <description>I am new to sas. I am trying to figure out how to import every excel file in a folder without naming each file.(apox 100) Also there is one sheet I am looking to grab from every file and combine them into one data set. I have done a lot of research but nothing has worked.</description>
      <pubDate>Tue, 14 Aug 2018 20:13:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Import-one-sheet-from-multiple-excel-files/m-p/486807#M15165</guid>
      <dc:creator>Spf2010</dc:creator>
      <dc:date>2018-08-14T20:13:55Z</dc:date>
    </item>
    <item>
      <title>Re: Import one sheet from multiple excel files</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Import-one-sheet-from-multiple-excel-files/m-p/486821#M15166</link>
      <description>&lt;P&gt;Here's one approach.&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, in my experience this won't work overall because when you use PROC IMPORT it guesses at types and the types will not be match across all files unless you happen to have really clean files.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you can convert them to CSV and customize the import procedure that's most likely to be the best way. In fact if it's all text files you can read them all at once into a single file relatively easily.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/226328"&gt;@Spf2010&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I am new to sas. I am trying to figure out how to import every excel file in a folder without naming each file.(apox 100) Also there is one sheet I am looking to grab from every file and combine them into one data set. I have done a lot of research but nothing has worked.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 20:26:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Import-one-sheet-from-multiple-excel-files/m-p/486821#M15166</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-14T20:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: Import one sheet from multiple excel files</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Import-one-sheet-from-multiple-excel-files/m-p/486826#M15167</link>
      <description>&lt;P&gt;You can use x-commands to read the files in a folder and then import. If you don't have access to run x-commands then the following approach might work for you.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;FILENAME _folder_ "%bquote(/usr/folder/)";/* Your path here */
data filenames(keep=memname);
FORMAT memname $100.;
  handle=dopen( '_folder_' );
  if handle &amp;gt; 0 then do;
    count=dnum(handle);
    do i=1 to count;
      memname=dread(handle,i);
      output filenames;
    end;
  end;
  rc=dclose(handle);
run;
filename _folder_ clear;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The above program reads all the files that are in the folder. No you can use the logic to filter your files (ie. by extensions or file names or etc.). Put those names in a macro using PROC SQL INTO .&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Count total files in the location and add all the file names into a macro */
PROC SQL noprint;
SELECT COUNT(*),memname INTO: Total_Files, : All_Files separated by "," 
FROM filenames;
QUIT;

%PUT "Total Files:" &amp;amp;Total_Files "All Files:" &amp;amp;All_Files;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Using a macro to loop through each file and import them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO IMPORT_FILES();
%DO I=1 %TO &amp;amp;Total_Files ;
%LET File=%SCAN("&amp;amp;All_Files",&amp;amp;i,",");
proc import 
  datafile="/usr/folder/&amp;amp;File."  /* Your folder path here */
  dbms=xlsx 
  out=GRIDWORK.TASK&amp;amp;i. 
  replace;
sheet="sheet1"; /* Your desired sheet here */
RUN;
%END;
%MEND IMPORT_FILES;
%IMPORT_FILES();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Finally Append all the datasets.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Append imported data into a single dataset */ 
%MACRO APPEND();
%DO I=2 %TO &amp;amp;Total_Files;
PROC APPEND BASE=WORK.Task1 DATA=WORK.Task&amp;amp;i. FORCE;
RUN;
%END;
%MEND APPEND;
%APPEND();&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Aug 2018 20:32:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Import-one-sheet-from-multiple-excel-files/m-p/486826#M15167</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-08-14T20:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: Import one sheet from multiple excel files</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Import-one-sheet-from-multiple-excel-files/m-p/486976#M15170</link>
      <description>The results from this is just one column name memname.Do you know why this would be?</description>
      <pubDate>Wed, 15 Aug 2018 13:02:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Import-one-sheet-from-multiple-excel-files/m-p/486976#M15170</guid>
      <dc:creator>Spf2010</dc:creator>
      <dc:date>2018-08-15T13:02:16Z</dc:date>
    </item>
    <item>
      <title>Re: Import one sheet from multiple excel files</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Import-one-sheet-from-multiple-excel-files/m-p/486980#M15171</link>
      <description>&lt;P&gt;Please post the code your trying and the log.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Aug 2018 13:21:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Import-one-sheet-from-multiple-excel-files/m-p/486980#M15171</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-08-15T13:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: Import one sheet from multiple excel files</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Import-one-sheet-from-multiple-excel-files/m-p/487004#M15175</link>
      <description>figured out the issue. However there are a lot of spaces and headings for each file when it appends. How do I clean that up?</description>
      <pubDate>Wed, 15 Aug 2018 14:36:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Import-one-sheet-from-multiple-excel-files/m-p/487004#M15175</guid>
      <dc:creator>Spf2010</dc:creator>
      <dc:date>2018-08-15T14:36:04Z</dc:date>
    </item>
    <item>
      <title>Re: Import one sheet from multiple excel files</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Import-one-sheet-from-multiple-excel-files/m-p/487013#M15176</link>
      <description>I tried the Range="sheet$A4:0" it didn't work.</description>
      <pubDate>Wed, 15 Aug 2018 14:57:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Import-one-sheet-from-multiple-excel-files/m-p/487013#M15176</guid>
      <dc:creator>Spf2010</dc:creator>
      <dc:date>2018-08-15T14:57:11Z</dc:date>
    </item>
    <item>
      <title>Re: Import one sheet from multiple excel files</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Import-one-sheet-from-multiple-excel-files/m-p/487014#M15177</link>
      <description>&lt;P&gt;You haven't provided much information. What files are you trying to import (xls, xlsx, csv,etc.)? Does your all files have first row with variables names and data starts from row 2? What code are you using?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Aug 2018 14:57:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Import-one-sheet-from-multiple-excel-files/m-p/487014#M15177</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-08-15T14:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: Import one sheet from multiple excel files</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Import-one-sheet-from-multiple-excel-files/m-p/487019#M15179</link>
      <description>Xlsx.The sheet has headers rows 1 to 4. Rows 5 and 6 the columns are merged for 2 or 3 columns and 2 or 3 are not.I can't post my code because of work rules. I am using Surya's code.</description>
      <pubDate>Wed, 15 Aug 2018 15:05:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Import-one-sheet-from-multiple-excel-files/m-p/487019#M15179</guid>
      <dc:creator>Spf2010</dc:creator>
      <dc:date>2018-08-15T15:05:02Z</dc:date>
    </item>
    <item>
      <title>Re: Import one sheet from multiple excel files</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Import-one-sheet-from-multiple-excel-files/m-p/487027#M15180</link>
      <description>&lt;P&gt;Make fake data and code and test it. Once it's working, you apply it to your real data. Often when following this process you'll usually solve the issues before posting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/226328"&gt;@Spf2010&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Xlsx.The sheet has headers rows 1 to 4. Rows 5 and 6 the columns are merged for 2 or 3 columns and 2 or 3 are not.I can't post my code because of work rules. I am using Surya's code.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Aug 2018 15:10:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Import-one-sheet-from-multiple-excel-files/m-p/487027#M15180</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-15T15:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: Import one sheet from multiple excel files</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Import-one-sheet-from-multiple-excel-files/m-p/487028#M15181</link>
      <description>&lt;P&gt;RANGE is only for xls files and will not work if your files are xlsx. I suggest you use GETNAMES=NO with DATAROW=n (n- row where data starts). Once the file is imported then rename the column names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternate approach, convert the files to CSV or txt and then use data step to read the files.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Aug 2018 15:13:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Import-one-sheet-from-multiple-excel-files/m-p/487028#M15181</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-08-15T15:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: Import one sheet from multiple excel files</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Import-one-sheet-from-multiple-excel-files/m-p/487036#M15182</link>
      <description>It get rid of the headers but I still have blank rowe between each dataset that appends</description>
      <pubDate>Wed, 15 Aug 2018 15:26:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Import-one-sheet-from-multiple-excel-files/m-p/487036#M15182</guid>
      <dc:creator>Spf2010</dc:creator>
      <dc:date>2018-08-15T15:26:42Z</dc:date>
    </item>
  </channel>
</rss>

