<?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 an excel file using macros in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Importing-an-excel-file-using-macros/m-p/778159#M247693</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/405308"&gt;@Lisa31&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So essentially, the solution from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;reads all tabs in the Excel file, regardless of what the tab names are, and turns them into SAS data sets. So no macro is needed. And therefore, the complications of writing working macros can be avoided, which in my mind is always a better solution.&lt;/P&gt;</description>
    <pubDate>Wed, 03 Nov 2021 12:11:17 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-11-03T12:11:17Z</dc:date>
    <item>
      <title>Importing an excel file using macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-an-excel-file-using-macros/m-p/778109#M247665</link>
      <description>I need to import an Excel file with 4 sheets in it using MACROS in sas</description>
      <pubDate>Wed, 03 Nov 2021 09:42:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-an-excel-file-using-macros/m-p/778109#M247665</guid>
      <dc:creator>Lisa31</dc:creator>
      <dc:date>2021-11-03T09:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: Importing an excel file using macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-an-excel-file-using-macros/m-p/778110#M247666</link>
      <description>&lt;P&gt;Why are macros needed for this task?&lt;/P&gt;</description>
      <pubDate>Wed, 03 Nov 2021 09:58:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-an-excel-file-using-macros/m-p/778110#M247666</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-11-03T09:58:36Z</dc:date>
    </item>
    <item>
      <title>Re: Importing an excel file using macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-an-excel-file-using-macros/m-p/778111#M247667</link>
      <description>I have been asked to use macros</description>
      <pubDate>Wed, 03 Nov 2021 09:59:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-an-excel-file-using-macros/m-p/778111#M247667</guid>
      <dc:creator>Lisa31</dc:creator>
      <dc:date>2021-11-03T09:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: Importing an excel file using macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-an-excel-file-using-macros/m-p/778114#M247668</link>
      <description>&lt;P&gt;First, write 4 Proc Import steps with 4 different Sheet = Options. If you want to do this using a macro, do it from there. And ask again and post the code you have written if you run into trouble &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Nov 2021 10:00:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-an-excel-file-using-macros/m-p/778114#M247668</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-11-03T10:00:47Z</dc:date>
    </item>
    <item>
      <title>Re: Importing an excel file using macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-an-excel-file-using-macros/m-p/778115#M247669</link>
      <description>We dont have to hardcode the sheet name</description>
      <pubDate>Wed, 03 Nov 2021 10:02:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-an-excel-file-using-macros/m-p/778115#M247669</guid>
      <dc:creator>Lisa31</dc:creator>
      <dc:date>2021-11-03T10:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: Importing an excel file using macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-an-excel-file-using-macros/m-p/778116#M247670</link>
      <description>%macro import_macro(x=,y=); proc import datafile-&amp;amp;x |dbms=xlsx out=&amp;amp;y replace;&lt;BR /&gt;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;%mend import_macro;&lt;BR /&gt;&lt;BR /&gt;%import_macro(x='path',y-Excelname);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;This is reading only the first sheet of the excel file</description>
      <pubDate>Wed, 03 Nov 2021 10:09:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-an-excel-file-using-macros/m-p/778116#M247670</guid>
      <dc:creator>Lisa31</dc:creator>
      <dc:date>2021-11-03T10:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: Importing an excel file using macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-an-excel-file-using-macros/m-p/778118#M247672</link>
      <description>&lt;P&gt;Part of learning a tool (like macros) is to know when NOT to use it. This isn't a great place to use it, but if you are going to create macros, you MUST create working SAS code without macros. If you don't have working SAS code without macros, then it simply will not work when you turn it into a macro. Most people (including you) ignore the advice to create working code without macros first. Please do things the proper way and the correct way and the way that will most likely produce positive results, by creating working code without macros first.&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/405308"&gt;@Lisa31&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;%macro import_macro(x=,y=); proc import datafile-&amp;amp;x |dbms=xlsx out=&amp;amp;y replace;&lt;BR /&gt;run;&lt;BR /&gt;%mend import_macro;&lt;BR /&gt;%import_macro(x='path',y-Excelname);&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You don't have working code here. You need to straighten that out first, before writing a macro. This part will NEVER work, whether or not it is in a macro, or not: &lt;FONT face="courier new,courier"&gt;datafile-&amp;amp;x&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why does it only read the first sheet? Again, creating working code without macros will get you there. Then you can turn it into a macro if you desire.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Nov 2021 10:26:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-an-excel-file-using-macros/m-p/778118#M247672</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-11-03T10:26:35Z</dc:date>
    </item>
    <item>
      <title>Re: Importing an excel file using macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-an-excel-file-using-macros/m-p/778124#M247677</link>
      <description>&lt;P&gt;In this case I recommend to use LIBNAME XLSX and PROC COPY:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname inex xlsx "/path/filename.xlsx";

proc copy
  in=inex
  out=target /* target library */
;
run;

libname inex clear;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The code will copy all sheets in the Excel file to the target library.&lt;/P&gt;
&lt;P&gt;Once you have this code running without issues, identify the parts that need to be dynamic, replace those with macro variables, and set the macro variables with %LET before testing again.&lt;/P&gt;
&lt;P&gt;Then wrap the code in a macro definition where you set the macro variables as parameters.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Nov 2021 10:36:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-an-excel-file-using-macros/m-p/778124#M247677</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-11-03T10:36:31Z</dc:date>
    </item>
    <item>
      <title>Re: Importing an excel file using macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-an-excel-file-using-macros/m-p/778159#M247693</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/405308"&gt;@Lisa31&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So essentially, the solution from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;reads all tabs in the Excel file, regardless of what the tab names are, and turns them into SAS data sets. So no macro is needed. And therefore, the complications of writing working macros can be avoided, which in my mind is always a better solution.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Nov 2021 12:11:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-an-excel-file-using-macros/m-p/778159#M247693</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-11-03T12:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: Importing an excel file using macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-an-excel-file-using-macros/m-p/779064#M248090</link>
      <description>&lt;P&gt;To make source and target dynamic, wrap the code into a macro:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro imp_excel(source,target);

libname inex xlsx "&amp;amp;source.";

proc copy
  in=inex
  out=&amp;amp;target. /* target library */
;
run;

libname inex clear;

%mend;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Nov 2021 07:36:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-an-excel-file-using-macros/m-p/779064#M248090</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-11-08T07:36:14Z</dc:date>
    </item>
  </channel>
</rss>

