<?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: How to import excel with &amp;quot;multiple sheets&amp;quot; and combine them? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-excel-with-quot-multiple-sheets-quot-and-combine/m-p/692420#M210945</link>
    <description>&lt;P&gt;See &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers/ta-p/352068" target="_self"&gt;Maxim 2&lt;/A&gt;: The log shows that each call of your macro creates/overwrites the same dataset. So you have to write each sheet to a different dataset first, than append them into a single dataset. Please note, that the last task may sound easy, but can be challenging, because excel doesn't have proper variable-types, forcing proc import to guess the types and set the length of alphanumeric variables depending on the values found in the data, most likely resulting in different lengths for a variable that seems to identical in all sheets.&lt;/P&gt;</description>
    <pubDate>Mon, 19 Oct 2020 05:05:09 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2020-10-19T05:05:09Z</dc:date>
    <item>
      <title>How to import excel with "multiple sheets" and combine them?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-excel-with-quot-multiple-sheets-quot-and-combine/m-p/692419#M210944</link>
      <description>&lt;P&gt;I have an excel files with 3 work sheets&amp;nbsp; for year 106, 107 and 108. each year has 100 observations with the same varoables. I wrtoe an macro, but WORK.a has only 100&amp;nbsp;observations. how do I merge the 300 obsevations together into work.a ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro pim(sheet);&lt;BR /&gt;proc import out= WORK.a&lt;BR /&gt;datafile = 'G:\data\106_108.xlsx'&lt;BR /&gt;DBMS=EXCEL replace;&lt;BR /&gt;sheet = "&amp;amp;sheet";&lt;BR /&gt;GETNAMES=YES;&lt;BR /&gt;run;&lt;BR /&gt;%mend pim;&lt;BR /&gt;%pim(106);&lt;BR /&gt;%pim(107);&lt;BR /&gt;%pim(108);&lt;/P&gt;&lt;P&gt;proc print data= WORK.a ;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Oct 2020 04:36:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-excel-with-quot-multiple-sheets-quot-and-combine/m-p/692419#M210944</guid>
      <dc:creator>tinghlin</dc:creator>
      <dc:date>2020-10-19T04:36:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to import excel with "multiple sheets" and combine them?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-excel-with-quot-multiple-sheets-quot-and-combine/m-p/692420#M210945</link>
      <description>&lt;P&gt;See &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers/ta-p/352068" target="_self"&gt;Maxim 2&lt;/A&gt;: The log shows that each call of your macro creates/overwrites the same dataset. So you have to write each sheet to a different dataset first, than append them into a single dataset. Please note, that the last task may sound easy, but can be challenging, because excel doesn't have proper variable-types, forcing proc import to guess the types and set the length of alphanumeric variables depending on the values found in the data, most likely resulting in different lengths for a variable that seems to identical in all sheets.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Oct 2020 05:05:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-excel-with-quot-multiple-sheets-quot-and-combine/m-p/692420#M210945</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-10-19T05:05:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to import excel with "multiple sheets" and combine them?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-excel-with-quot-multiple-sheets-quot-and-combine/m-p/692424#M210949</link>
      <description>&lt;P&gt;As your excel file is of xlsx type, you can try next code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname myxlsx xlsx "G:\data\106_108.xlsx";

data want;
  set myxlsx.'106'n
      myxlsx.'107'n
      myxlsx.'108'n
  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;it will be better if sheet names will be renamed into "s016", "s107", "s108"&lt;/P&gt;
&lt;P&gt;then the code can be adapted to:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname myxlsx xlsx "G:\data\106_108.xlsx";

data want;
  set myxlsx.s106
      myxlsx.s107
      myxlsx.s108
  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Oct 2020 05:29:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-excel-with-quot-multiple-sheets-quot-and-combine/m-p/692424#M210949</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-10-19T05:29:20Z</dc:date>
    </item>
  </channel>
</rss>

