<?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: Transferring sheets from one excel file to another in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Transferring-sheets-from-one-excel-file-to-another/m-p/619357#M181817</link>
    <description>This will not copy the image files though..</description>
    <pubDate>Wed, 22 Jan 2020 22:51:59 GMT</pubDate>
    <dc:creator>SP_SAS</dc:creator>
    <dc:date>2020-01-22T22:51:59Z</dc:date>
    <item>
      <title>Transferring sheets from one excel file to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transferring-sheets-from-one-excel-file-to-another/m-p/619340#M181810</link>
      <description>&lt;P&gt;I have two .xlsx files that both have data and images. I want to combine the sheets of both the excel files into one.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I did a simple thing like&lt;/P&gt;
&lt;P&gt;libname a xlsx "myfile1.xlsx";&amp;nbsp; (has two sheets sheeta1 sheeta2)&lt;/P&gt;
&lt;P&gt;libname b xlsx "myfile2.xlsx"; (has two sheets sheetb1 sheetb2)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data a.sheetb1;&lt;/P&gt;
&lt;P&gt;set b.sheetb1;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data a.sheetb2;&lt;/P&gt;
&lt;P&gt;set b.sheetb2;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This copies the data fine but does not copy the images. the final file myfile1.xlsx has 4 sheets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I keep the images also when I do this kind of copy.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If SAS can't do it. Can Python do it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2020 22:09:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transferring-sheets-from-one-excel-file-to-another/m-p/619340#M181810</guid>
      <dc:creator>SP_SAS</dc:creator>
      <dc:date>2020-01-22T22:09:37Z</dc:date>
    </item>
    <item>
      <title>Re: Transferring sheets from one excel file to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transferring-sheets-from-one-excel-file-to-another/m-p/619355#M181816</link>
      <description>&lt;P&gt;If that's a one-off task then I'd do this manually as it's really simple and quick using Excel.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't believe there is a straightforward way using SAS other than calling Windows/Excel to do the job for you (which means the process needs to execute in an environment where Excel is installed).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like the Python Pandas package would allow you to do such a 1:1 copy of a sheet. Not sure though if this still requires Excel installed on the same machine and Pandas is just calling these Excel components internally.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/44593705/how-to-copy-over-an-excel-sheet-to-another-workbook-in-python" target="_blank" rel="noopener"&gt;https://stackoverflow.com/questions/44593705/how-to-copy-over-an-excel-sheet-to-another-workbook-in-python&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="lang-py prettyprint prettyprinted"&gt;&lt;CODE&gt;&lt;SPAN class="kwd"&gt;import&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; pandas &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;as&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; pd

&lt;/SPAN&gt;&lt;SPAN class="com"&gt;#change xxx with the sheet name that includes the data&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;
data &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; pd&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;read_excel&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;sourcefile&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; sheet_name&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="str"&gt;"xxx"&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="com"&gt;#save it to the 'new_tab' in destfile&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;
data&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;to_excel&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;destfile&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; sheet_name&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="str"&gt;'new_tab'&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2020 22:41:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transferring-sheets-from-one-excel-file-to-another/m-p/619355#M181816</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-01-22T22:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: Transferring sheets from one excel file to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transferring-sheets-from-one-excel-file-to-another/m-p/619357#M181817</link>
      <description>This will not copy the image files though..</description>
      <pubDate>Wed, 22 Jan 2020 22:51:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transferring-sheets-from-one-excel-file-to-another/m-p/619357#M181817</guid>
      <dc:creator>SP_SAS</dc:creator>
      <dc:date>2020-01-22T22:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: Transferring sheets from one excel file to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transferring-sheets-from-one-excel-file-to-another/m-p/619362#M181822</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/28953"&gt;@SP_SAS&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;OK, then it appears the same answer I've given for SAS also applies for Python unless someone wrote a package which does the copying the way you need it - but that's then likely the same like finding somewhere an already written SAS macro which does such a copy. I guess both would need to call Windows/MS Office components.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2020 23:05:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transferring-sheets-from-one-excel-file-to-another/m-p/619362#M181822</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-01-22T23:05:54Z</dc:date>
    </item>
    <item>
      <title>Re: Transferring sheets from one excel file to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transferring-sheets-from-one-excel-file-to-another/m-p/619363#M181823</link>
      <description>Then use VBS and call that VBS from Python or SAS.</description>
      <pubDate>Wed, 22 Jan 2020 23:06:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transferring-sheets-from-one-excel-file-to-another/m-p/619363#M181823</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-01-22T23:06:28Z</dc:date>
    </item>
    <item>
      <title>Re: Transferring sheets from one excel file to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transferring-sheets-from-one-excel-file-to-another/m-p/619373#M181826</link>
      <description>&lt;P&gt;Behind the scenes SAS is importing the data from one sheet in your source workbook then writing that data out to a sheet in your target workbook. Anything that can't be stored in a SAS dataset like images wont be included.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2020 23:24:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transferring-sheets-from-one-excel-file-to-another/m-p/619373#M181826</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-01-22T23:24:14Z</dc:date>
    </item>
  </channel>
</rss>

