<?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 update xlsx file use libname---------SAS 9.3 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-update-xlsx-file-use-libname-SAS-9-3/m-p/354820#M83056</link>
    <description>&lt;P&gt;Hello PG,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;AAAA.xlsx has three sheets:&amp;nbsp;sheet1, sheet2, sheet3&lt;/SPAN&gt;&lt;BR /&gt;libname XL excel 'C:\temp\AAAA.xlsx';&lt;BR /&gt;After I use&amp;nbsp;&lt;SPAN&gt;libname XL excel , the XL folder has three sheets: sheet1&lt;STRONG&gt;$&lt;/STRONG&gt;, sheet2&lt;STRONG&gt;$&lt;/STRONG&gt;, sheet3&lt;STRONG&gt;$&lt;/STRONG&gt; (There is a &lt;STRONG&gt;$&lt;/STRONG&gt; follow each sheet name )&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;drop table XL.'Sheet3$'n;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;data XL.Sheet3;&lt;BR /&gt;set sashelp.class;&lt;BR /&gt;w=2;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;libname XL clear;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;The old Sheet3 will be still there, but the new one I just created will become sheet&lt;STRONG&gt;31&lt;/STRONG&gt;. that is so wired.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 30 Apr 2017 17:37:15 GMT</pubDate>
    <dc:creator>GeorgeSAS</dc:creator>
    <dc:date>2017-04-30T17:37:15Z</dc:date>
    <item>
      <title>how to update xlsx file use libname---------SAS 9.3</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-update-xlsx-file-use-libname-SAS-9-3/m-p/354670#M82995</link>
      <description>&lt;P&gt;libname mylib&amp;nbsp;excel 'C:\temp\aaaaaa.xlsx';&lt;/P&gt;
&lt;P&gt;I use the excel engine can make connection to the xlsx file, all data name end with "$";(I can't use libname xlsx,The XLSX engine cannot be found)&lt;/P&gt;
&lt;P&gt;I can read but I can't wirte.please help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This works:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; data DATA_PWZ; &lt;BR /&gt;&amp;nbsp; &amp;nbsp;set xx2.sheet_new; &lt;BR /&gt;&amp;nbsp; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This doesn't work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; data &lt;SPAN&gt;mylib&lt;/SPAN&gt;.sheet_new; &lt;BR /&gt;&amp;nbsp; set &lt;SPAN&gt;mylib&lt;/SPAN&gt;.sheet_new; &lt;BR /&gt;&amp;nbsp; if year=2000 then freq=freq/2;&lt;BR /&gt;&amp;nbsp; run;&lt;/P&gt;</description>
      <pubDate>Sat, 29 Apr 2017 03:30:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-update-xlsx-file-use-libname-SAS-9-3/m-p/354670#M82995</guid>
      <dc:creator>GeorgeSAS</dc:creator>
      <dc:date>2017-04-29T03:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: how to update xlsx file use libname---------SAS 9.3</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-update-xlsx-file-use-libname-SAS-9-3/m-p/354675#M82997</link>
      <description>&lt;P&gt;The key thing to understand here is Excel is not a proper database which means you can't update "in-place". You can't read from an Excel sheet and then update it all in the one step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The solution is to read the Excel sheet into a SAS table, make all the necessary changes, then write the SAS table back to Excel:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DATA_PWZ; 
  set xx2.sheet_new;
  if year=2000 then freq=freq/2;
run;
 
data mylib.sheet_new; 
  set DATA_PWZ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 29 Apr 2017 03:51:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-update-xlsx-file-use-libname-SAS-9-3/m-p/354675#M82997</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2017-04-29T03:51:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to update xlsx file use libname---------SAS 9.3</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-update-xlsx-file-use-libname-SAS-9-3/m-p/354676#M82998</link>
      <description>&lt;P&gt;This should work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Connect to the workbook */
libname mylib Excel 'C:\temp\aaaaaa.xlsx';

/* Read a table */
data one;
set mylib.'myData$'n;
run;

/* Delete the table if you want to overwrite */
proc sql
drop table mylib.'myData$'n;
quit;

/* Write the new table */
data mylib.myData;
set one;
if year=2000 then freq=freq/2;
run;

/* Close the connexion */
libname mylib clear;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 29 Apr 2017 03:56:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-update-xlsx-file-use-libname-SAS-9-3/m-p/354676#M82998</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-04-29T03:56:59Z</dc:date>
    </item>
    <item>
      <title>Re: how to update xlsx file use libname---------SAS 9.3</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-update-xlsx-file-use-libname-SAS-9-3/m-p/354677#M82999</link>
      <description>&lt;P&gt;If I was right, you need define an option .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;libname mylib&amp;nbsp;excel 'C:\temp\aaaaaa.xlsx' scan_text=no ;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;also could try SQL.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;proc sql;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;update mylib.sheet&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;set freq=freq/2&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;where year=2012 ;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 29 Apr 2017 04:06:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-update-xlsx-file-use-libname-SAS-9-3/m-p/354677#M82999</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-04-29T04:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: how to update xlsx file use libname---------SAS 9.3</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-update-xlsx-file-use-libname-SAS-9-3/m-p/354766#M83027</link>
      <description>I can't delete the  table.&lt;BR /&gt;If I use drop, it will auto recovery the sheet ,what I can do?</description>
      <pubDate>Sun, 30 Apr 2017 02:00:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-update-xlsx-file-use-libname-SAS-9-3/m-p/354766#M83027</guid>
      <dc:creator>GeorgeSAS</dc:creator>
      <dc:date>2017-04-30T02:00:41Z</dc:date>
    </item>
    <item>
      <title>Re: how to update xlsx file use libname---------SAS 9.3</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-update-xlsx-file-use-libname-SAS-9-3/m-p/354770#M83029</link>
      <description>&lt;P&gt;What error message do you get?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should be able to drop the table. Make sure the file is not opened by some other process when you do.&lt;/P&gt;</description>
      <pubDate>Sun, 30 Apr 2017 02:56:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-update-xlsx-file-use-libname-SAS-9-3/m-p/354770#M83029</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-04-30T02:56:38Z</dc:date>
    </item>
    <item>
      <title>Re: how to update xlsx file use libname---------SAS 9.3</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-update-xlsx-file-use-libname-SAS-9-3/m-p/354773#M83031</link>
      <description>no error message, just the table can't be droped</description>
      <pubDate>Sun, 30 Apr 2017 03:09:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-update-xlsx-file-use-libname-SAS-9-3/m-p/354773#M83031</guid>
      <dc:creator>GeorgeSAS</dc:creator>
      <dc:date>2017-04-30T03:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: how to update xlsx file use libname---------SAS 9.3</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-update-xlsx-file-use-libname-SAS-9-3/m-p/354774#M83032</link>
      <description>no error, just table can't be drop</description>
      <pubDate>Sun, 30 Apr 2017 03:09:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-update-xlsx-file-use-libname-SAS-9-3/m-p/354774#M83032</guid>
      <dc:creator>GeorgeSAS</dc:creator>
      <dc:date>2017-04-30T03:09:38Z</dc:date>
    </item>
    <item>
      <title>Re: how to update xlsx file use libname---------SAS 9.3</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-update-xlsx-file-use-libname-SAS-9-3/m-p/354776#M83034</link>
      <description>&lt;P&gt;Note, I should have mentioned that it will not remove the sheet (or named range if you use a range), it will only delete the cell contents. You should be able to overwrite the table after.&lt;/P&gt;</description>
      <pubDate>Sun, 30 Apr 2017 03:26:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-update-xlsx-file-use-libname-SAS-9-3/m-p/354776#M83034</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-04-30T03:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: how to update xlsx file use libname---------SAS 9.3</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-update-xlsx-file-use-libname-SAS-9-3/m-p/354820#M83056</link>
      <description>&lt;P&gt;Hello PG,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;AAAA.xlsx has three sheets:&amp;nbsp;sheet1, sheet2, sheet3&lt;/SPAN&gt;&lt;BR /&gt;libname XL excel 'C:\temp\AAAA.xlsx';&lt;BR /&gt;After I use&amp;nbsp;&lt;SPAN&gt;libname XL excel , the XL folder has three sheets: sheet1&lt;STRONG&gt;$&lt;/STRONG&gt;, sheet2&lt;STRONG&gt;$&lt;/STRONG&gt;, sheet3&lt;STRONG&gt;$&lt;/STRONG&gt; (There is a &lt;STRONG&gt;$&lt;/STRONG&gt; follow each sheet name )&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;drop table XL.'Sheet3$'n;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;data XL.Sheet3;&lt;BR /&gt;set sashelp.class;&lt;BR /&gt;w=2;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;libname XL clear;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;The old Sheet3 will be still there, but the new one I just created will become sheet&lt;STRONG&gt;31&lt;/STRONG&gt;. that is so wired.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 30 Apr 2017 17:37:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-update-xlsx-file-use-libname-SAS-9-3/m-p/354820#M83056</guid>
      <dc:creator>GeorgeSAS</dc:creator>
      <dc:date>2017-04-30T17:37:15Z</dc:date>
    </item>
    <item>
      <title>Re: how to update xlsx file use libname---------SAS 9.3</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-update-xlsx-file-use-libname-SAS-9-3/m-p/354967#M83108</link>
      <description>&lt;P&gt;Thank Ksharp's idiea,I need do some revise,firstly I have to save xlsx as xls.then..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;libname XL excel 'C:\temp\test\thiswork.xls' SCAN_TEXT=NO;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;update xl.'Sheet3$'n &lt;BR /&gt; set b=999&lt;BR /&gt; where a=888&lt;BR /&gt; ;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;libname _all_ clear;&lt;/P&gt;</description>
      <pubDate>Mon, 01 May 2017 15:59:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-update-xlsx-file-use-libname-SAS-9-3/m-p/354967#M83108</guid>
      <dc:creator>GeorgeSAS</dc:creator>
      <dc:date>2017-05-01T15:59:41Z</dc:date>
    </item>
  </channel>
</rss>

