<?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 importing multiple excel files to SAS datasets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/importing-multiple-excel-files-to-SAS-datasets/m-p/299255#M63067</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi SAS Users,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am converting excel to SAS dataset with the following code.&lt;/P&gt;&lt;P&gt;now I want to convert around 10 excel files to SAS datasets. instead of writing 10 time this same code can we have macro here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using SAS EG 9.4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;x 'dos2unix -437 /&lt;SPAN&gt;D&lt;/SPAN&gt;/Raju/Compare/AE_details.csv /&lt;SPAN&gt;D/&lt;/SPAN&gt;Raju/Compare/AE_details.csv';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC IMPORT&lt;BR /&gt;DATAFILE="/D/Raju/Compare/AE_details.csv"&lt;BR /&gt;OUT = ae REPLACE&lt;BR /&gt;DBMS=csv;&lt;BR /&gt;GETNAMES=YES;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data ae_details;&lt;BR /&gt;set work.ae;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;KR,&lt;/P&gt;&lt;P&gt;Raju&lt;/P&gt;</description>
    <pubDate>Mon, 19 Sep 2016 12:10:37 GMT</pubDate>
    <dc:creator>Raj_C</dc:creator>
    <dc:date>2016-09-19T12:10:37Z</dc:date>
    <item>
      <title>importing multiple excel files to SAS datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-multiple-excel-files-to-SAS-datasets/m-p/299255#M63067</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi SAS Users,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am converting excel to SAS dataset with the following code.&lt;/P&gt;&lt;P&gt;now I want to convert around 10 excel files to SAS datasets. instead of writing 10 time this same code can we have macro here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using SAS EG 9.4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;x 'dos2unix -437 /&lt;SPAN&gt;D&lt;/SPAN&gt;/Raju/Compare/AE_details.csv /&lt;SPAN&gt;D/&lt;/SPAN&gt;Raju/Compare/AE_details.csv';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC IMPORT&lt;BR /&gt;DATAFILE="/D/Raju/Compare/AE_details.csv"&lt;BR /&gt;OUT = ae REPLACE&lt;BR /&gt;DBMS=csv;&lt;BR /&gt;GETNAMES=YES;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data ae_details;&lt;BR /&gt;set work.ae;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;KR,&lt;/P&gt;&lt;P&gt;Raju&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2016 12:10:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-multiple-excel-files-to-SAS-datasets/m-p/299255#M63067</guid>
      <dc:creator>Raj_C</dc:creator>
      <dc:date>2016-09-19T12:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: importing multiple excel files to SAS datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-multiple-excel-files-to-SAS-datasets/m-p/299271#M63071</link>
      <description>&lt;P&gt;First, wrap your code into a macro definition:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro import_excel(infile);

x "dos2unix -437 /D/Raju/Compare/&amp;amp;infile..csv /D/Raju/Compare/&amp;amp;infile..csv";

PROC IMPORT
DATAFILE="/D/Raju/Compare/&amp;amp;infile..csv"
OUT = &amp;amp;infile REPLACE
DBMS=csv;
GETNAMES=YES;
RUN;

%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then, write your filenames into a control dataset:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data control;
length filename $30; *just to be sure;
input filename $;
cards;
AE_details
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then, execute your macro from that dataset:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set control;
call execute('%import_excel('!!strip(filename)!!');');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Sep 2016 12:55:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-multiple-excel-files-to-SAS-datasets/m-p/299271#M63071</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-09-19T12:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: importing multiple excel files to SAS datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-multiple-excel-files-to-SAS-datasets/m-p/299277#M63072</link>
      <description>&lt;P&gt;Do you have a CSV or Excel file?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is each file different?&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2016 13:27:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-multiple-excel-files-to-SAS-datasets/m-p/299277#M63072</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-09-19T13:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: importing multiple excel files to SAS datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-multiple-excel-files-to-SAS-datasets/m-p/299289#M63074</link>
      <description>&lt;P&gt;I am having Excel files. but when I tried with DBMS = xlsx it is giving following error. so I saved all files to CSV manually then imported.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: XLSX file does not exist.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;all files are in same format.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2016 14:06:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-multiple-excel-files-to-SAS-datasets/m-p/299289#M63074</guid>
      <dc:creator>Raj_C</dc:creator>
      <dc:date>2016-09-19T14:06:59Z</dc:date>
    </item>
    <item>
      <title>Re: importing multiple excel files to SAS datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-multiple-excel-files-to-SAS-datasets/m-p/299291#M63075</link>
      <description>&lt;P&gt;As an addendum, I'd like to note that in a production environment I would not rely on proc import; instead every infile would get its hand-tailored data step. Which shall respond with a fail if the input structure (or values/types) changes unexpectedly.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2016 14:12:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-multiple-excel-files-to-SAS-datasets/m-p/299291#M63075</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-09-19T14:12:16Z</dc:date>
    </item>
    <item>
      <title>Re: importing multiple excel files to SAS datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-multiple-excel-files-to-SAS-datasets/m-p/299305#M63080</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;If you happen to be using the old text editor you can run these dm commands. Also you can type one on the command line, hit the submit mouse button then '?' to get last submitted command, edit an submit.

You can also chain command line statements by separating them with a ';'

However as has been stated, your CSVs cannot have issues with headers or data.

I like to highlight one at a time and hit RMB.

dm "dimport 'c:\temp\tmp0.csv' class0  replace";
dm "dimport 'c:\temp\tmp1.csv' class1  replace";
dm "dimport 'c:\temp\tmp2.csv' class2  replace";
dm "dimport 'c:\temp\tmp3.csv' class3  replace";
dm "dimport 'c:\temp\tmp4.csv' class4  replace";
dm "dimport 'c:\temp\tmp5.csv' class5  replace";
dm "dimport 'c:\temp\tmp6.csv' class6  replace";
dm "dimport 'c:\temp\tmp7.csv' class7  replace";
dm "dimport 'c:\temp\tmp8.csv' class8  replace";
dm "dimport 'c:\temp\tmp9.csv' class9  replace";&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Sep 2016 14:52:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-multiple-excel-files-to-SAS-datasets/m-p/299305#M63080</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2016-09-19T14:52:54Z</dc:date>
    </item>
  </channel>
</rss>

