<?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: Can you protect a Excel worksheet from within a SAS procedure or data step? in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Can-you-protect-a-Excel-worksheet-from-within-a-SAS-procedure-or/m-p/132793#M10865</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you so much, "data_null;"&amp;nbsp;&amp;nbsp; .&lt;/P&gt;&lt;P&gt;I will be producing multiple separate worksheets, each filtered on a different variable in the file, using PROC REPORT.&amp;nbsp; Where in the program, do I need to place the call to this stored program ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 11 Jun 2012 20:20:47 GMT</pubDate>
    <dc:creator>chandler</dc:creator>
    <dc:date>2012-06-11T20:20:47Z</dc:date>
    <item>
      <title>Can you protect a Excel worksheet from within a SAS procedure or data step?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Can-you-protect-a-Excel-worksheet-from-within-a-SAS-procedure-or/m-p/132791#M10863</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;I use SAS for Windows, v9.2 TS2M3, on Windows XP Professional operating system.&amp;nbsp;&amp;nbsp; I have some report requests, to be ouput via ODS to Excel spreadsheets (preferably Excel 2007), but the sheets need to be password protected to prevent modifications to the reports.&amp;nbsp; Is there a way to password protect a output Excel spreadsheet, but do it from SAS, not manually from Excel, after-the-fact?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jun 2012 19:57:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Can-you-protect-a-Excel-worksheet-from-within-a-SAS-procedure-or/m-p/132791#M10863</guid>
      <dc:creator>chandler</dc:creator>
      <dc:date>2012-06-05T19:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: Can you protect a Excel worksheet from within a SAS procedure or data step?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Can-you-protect-a-Excel-worksheet-from-within-a-SAS-procedure-or/m-p/132792#M10864</link>
      <description>&lt;P&gt;This program opens an XML file in Execl and saves it as an XLSX with the&lt;/P&gt;
&lt;DL&gt;
&lt;DT&gt;&lt;SPAN class="parameter"&gt;WriteResPassword&lt;/SPAN&gt;&lt;/DT&gt;
&lt;DD&gt;
&lt;P&gt;The write-reservation password for this file. If a file is saved with the password and the password is not supplied when the file is opened, the file is opened as read-only.&lt;/P&gt;
&lt;/DD&gt;
&lt;/DL&gt;
&lt;P&gt;This way it can be opened readonly without know anything.&amp;nbsp; I like not having to know anything.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_ / pgm=work.xml2xlsx;
   /* gather info */
   length xml xlsx $256 script filevar command $256;
   xml = pathname('FT67F001');
   xlsx = xml;
   substr(xlsx,find(xml,'.',-length(xml)))='.xlsx';
   put xml= xlsx=;
   script   = catx('\',pathname('WORK'),'XML2xlsx.vbs');
   filevar  = script;

   /* write the script */
   file dummy1 filevar=filevar;
   put 'Const ' xml=$quote256.;
   put 'Const ' xlsx=$quote256.;
   *put 'Const xlCSV = 6';
   put 'Const xlWorkbookNormal = 51';
 

   put 'Set objExcel = CreateObject("Excel.Application")';
   put 'With objExcel';
   put +3 '.Visible = False';
   put +3 '.DisplayAlerts = False';
   put +3 'Set objWorkbook  = .Workbooks.Open(xml)';
   put +3 'objWorkBook.SaveAs xlsx,xlWorkbookNormal,"","WritePass"';
   put +3 '.Application.Quit';
   put +3 'End With';
 

   /* close the script file by opening another, not used */
   filevar = catx('\',pathname('WORK'),'DUMMY.vbs');
   file dummy1 filevar=filevar;
   /* look at the script, not necessary but may be useful */
   infile dummy2 filevar=script end=eof;
   do _n_ = 1 by 1 while(not eof);
      input;
      putlog _n_ 3. +2 _infile_;
      end;
   /* call the script */
   command = catx(' ','cscript',quote(strip(script)),'//nologo');
   infile dummy3 pipe filevar=command end=eof truncover;
   do while(not eof);
      input;
      putlog _infile_;
      end;
   stop;
   run;

filename FT67F001 'testXP.xml';
ods results off;
ods tagsets.excelxp file=FT67F001;
proc print data=sashelp.class;
   run;
ods tagsets.excelxp close;
 
data pgm=work.xml2xlsx;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The stored program can be saved in a library and called simply as &lt;STRONG&gt;data pgm=work.xml2xlsx;&lt;/STRONG&gt;&amp;nbsp; The only required input is the FILEREF FT67F001.&lt;/P&gt;</description>
      <pubDate>Mon, 07 May 2018 14:52:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Can-you-protect-a-Excel-worksheet-from-within-a-SAS-procedure-or/m-p/132792#M10864</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2018-05-07T14:52:02Z</dc:date>
    </item>
    <item>
      <title>Re: Can you protect a Excel worksheet from within a SAS procedure or data step?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Can-you-protect-a-Excel-worksheet-from-within-a-SAS-procedure-or/m-p/132793#M10865</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you so much, "data_null;"&amp;nbsp;&amp;nbsp; .&lt;/P&gt;&lt;P&gt;I will be producing multiple separate worksheets, each filtered on a different variable in the file, using PROC REPORT.&amp;nbsp; Where in the program, do I need to place the call to this stored program ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jun 2012 20:20:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Can-you-protect-a-Excel-worksheet-from-within-a-SAS-procedure-or/m-p/132793#M10865</guid>
      <dc:creator>chandler</dc:creator>
      <dc:date>2012-06-11T20:20:47Z</dc:date>
    </item>
    <item>
      <title>Re: Can you protect a Excel worksheet from within a SAS procedure or data step?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Can-you-protect-a-Excel-worksheet-from-within-a-SAS-procedure-or/m-p/132794#M10866</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;
&lt;P&gt;chandler wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Thank you so much, "data_null;"&amp;nbsp;&amp;nbsp; .&lt;/P&gt;
&lt;P&gt;I will be producing multiple separate worksheets, each filtered on a different variable in the file, using PROC REPORT.&amp;nbsp; Where in the program, do I need to place the call to this stored program ?&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;I'm not sure I understand "multiple separate worksheets".&amp;nbsp; I do understand "multiple separate workbooks" aka an excel file.&amp;nbsp; Notice in the sample program I used a fileref FT67F001 to define a new workbook.&amp;nbsp; Then I created some output in that workbook.&amp;nbsp; It could have been multiple sheets but it wasn't.&amp;nbsp; The output I create was excel(XML) using tagsets.excelxp.&amp;nbsp; Is that how your are creating your workbooks?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;filename&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt; FT67F001 &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: purple; font-family: 'Courier New';"&gt;'testXP.xml'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;ods&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt; results &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;off&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;ods&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt; tagsets.excelxp &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;file&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;=FT67F001;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: navy; font-family: 'Courier New';"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; background: white; color: navy; font-family: 'Courier New';"&gt;&lt;STRONG&gt;print&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;data&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;=sashelp.class;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; background: white; color: navy; font-family: 'Courier New';"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;ods&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt; tagsets.excelxp &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;close&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once the file has been written and closed then you can call the stored program.&amp;nbsp; Also note this converts the XML to XLSX and adds the password. If you want to use the program as a stored program you will need to "read up" on that.&amp;nbsp; Or you could just make the data step a macro.&amp;nbsp; This might be easiest if you have other autocall macros already set up for your project.&amp;nbsp; If this doesn't answer your question let me know.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: navy; font-family: 'Courier New';"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;pgm&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;=work.xml2xlsx;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; background: white; color: navy; font-family: 'Courier New';"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jun 2012 21:56:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Can-you-protect-a-Excel-worksheet-from-within-a-SAS-procedure-or/m-p/132794#M10866</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2012-06-11T21:56:17Z</dc:date>
    </item>
    <item>
      <title>Re: Can you protect a Excel worksheet from within a SAS procedure or data step?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Can-you-protect-a-Excel-worksheet-from-within-a-SAS-procedure-or/m-p/254725#M15349</link>
      <description>&lt;P&gt;The code worked like a charm however, how can I remove &amp;nbsp;'read only' . I only want the excel document to be password protected. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Mar 2016 15:40:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Can-you-protect-a-Excel-worksheet-from-within-a-SAS-procedure-or/m-p/254725#M15349</guid>
      <dc:creator>R_Anderson</dc:creator>
      <dc:date>2016-03-05T15:40:28Z</dc:date>
    </item>
  </channel>
</rss>

