<?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: Create a Read-Only Excel File from SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-a-Read-Only-Excel-File-from-SAS/m-p/678245#M204687</link>
    <description>&lt;P&gt;Hi &lt;A class="trigger-hovercard" style="color: #007dc3;" href="https://communities.sas.com/t5/user/viewprofilepage/user-id/74" target="_blank" rel="noopener"&gt;djbateman&lt;/A&gt;,&lt;/P&gt;
&lt;P&gt;You can define your file permissions in the filename statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename f "&amp;amp;default\temp.vbs" permission='A::u::rwx,A::g::r-x,A::o::---';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then use in your data step as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   file f;
   . . .&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For more information on assigning files permissions programmatically see my blog post &lt;A href="https://blogs.sas.com/content/sgf/2018/01/25/let-sas-write-batch-scripts/" target="_self"&gt;Let SAS write batch scripts for you.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Hope this helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 20 Aug 2020 22:25:50 GMT</pubDate>
    <dc:creator>LeonidBatkhan</dc:creator>
    <dc:date>2020-08-20T22:25:50Z</dc:date>
    <item>
      <title>Create a Read-Only Excel File from SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-Read-Only-Excel-File-from-SAS/m-p/678235#M204684</link>
      <description>&lt;P&gt;I am trying to create a read-only Excel file from SAS.&amp;nbsp; I have found a lot of methods that will do the trick, but I can't seem to get any of them to work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tried using the X commands:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;x 'attrib +r "S:\cdm\Programming\OutputFile_&amp;amp;sysdate9..xlsx"';
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I tried r+ and +r with no luck.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tried the protect_worksheet='no' option in ODS EXCEL with no luck.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tried applying at password as found here:&amp;nbsp;&amp;nbsp;&lt;A href="https://support.sas.com/kb/31/328.html" target="_blank"&gt;https://support.sas.com/kb/31/328.html&lt;/A&gt;&amp;nbsp; with no luck.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think I have narrowed it down to altering a macro that I am already using that just needs another parameter, but I don't know the VBA syntax.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro convert_files(default=,ext=);
	data _null_;
		file "'&amp;amp;default\temp.vbs'";
		put "set xlapp = CreateObject(""Excel.Application"")";
		put "set fso = CreateObject(""scripting.filesystemobject"")";
		put "set myfolder = fso.GetFolder(""&amp;amp;default"")";
		put "set myfiles = myfolder.Files";
		put "xlapp.DisplayAlerts = False";
		put " ";
		put "for each f in myfiles";
		put "If f.Size &amp;lt; 70000 And fso.GetExtensionName(f)=""&amp;amp;ext"" Then";
		put "  f.Delete True";
		put "    End If";
		put "  Next";
		put " ";
		put "for each f in myfiles";
		put "  ExtName = fso.GetExtensionName(f)";
		put "  Filename= fso.GetBaseName(f)";
		put "    if ExtName=""&amp;amp;ext"" then";
		put "           set mybook = xlapp.Workbooks.Open(f.Path)"; 
		put "           xlapp.Visible = false";
		put "           mybook.SaveAs ""&amp;amp;default.\"" &amp;amp; Filename &amp;amp; "".xlsx"", 51";
		put "    End If";
		put "  Next";
		put "  mybook.Close";
		put "  xlapp.DisplayAlerts = True";
		/* Removes original files */
		put " FSO.DeleteFile(""&amp;amp;default\*.&amp;amp;ext""), DeleteReadOnly";
		put " xlapp.Quit";
		put " Set xlapp = Nothing";
		put " strScript = Wscript.ScriptFullName";
		put " FSO.DeleteFile(strScript)"; 
	run; 
 
	x "cscript ""&amp;amp;default\temp.vbs""";
%mend;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This macro is what we use to convert XML files to XLSX.&amp;nbsp; There is a &lt;STRONG&gt;SaveAs&lt;/STRONG&gt; line in the macro where I specify the filename and the file type.&amp;nbsp; After that is supposed to be allowance to specify a password, backup, and read-only option, but I don't know how to alter it to get what I want.&amp;nbsp; Does anyone have any suggestions for my alteration or a different way to make a file read only?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Aug 2020 19:30:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-Read-Only-Excel-File-from-SAS/m-p/678235#M204684</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2020-08-20T19:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Read-Only Excel File from SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-Read-Only-Excel-File-from-SAS/m-p/678245#M204687</link>
      <description>&lt;P&gt;Hi &lt;A class="trigger-hovercard" style="color: #007dc3;" href="https://communities.sas.com/t5/user/viewprofilepage/user-id/74" target="_blank" rel="noopener"&gt;djbateman&lt;/A&gt;,&lt;/P&gt;
&lt;P&gt;You can define your file permissions in the filename statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename f "&amp;amp;default\temp.vbs" permission='A::u::rwx,A::g::r-x,A::o::---';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then use in your data step as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   file f;
   . . .&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For more information on assigning files permissions programmatically see my blog post &lt;A href="https://blogs.sas.com/content/sgf/2018/01/25/let-sas-write-batch-scripts/" target="_self"&gt;Let SAS write batch scripts for you.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Hope this helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Aug 2020 22:25:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-Read-Only-Excel-File-from-SAS/m-p/678245#M204687</guid>
      <dc:creator>LeonidBatkhan</dc:creator>
      <dc:date>2020-08-20T22:25:50Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Read-Only Excel File from SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-Read-Only-Excel-File-from-SAS/m-p/678268#M204692</link>
      <description>Thanks for your input.  I didn't quite follow your suggestion, but I was able to get my issue resolved.  I was able to use the +r attribute with the X statement.  I just had to remove the single quotes:&lt;BR /&gt;&lt;BR /&gt;x attrib +r "S:\cdm\Programming\OutputFile_&amp;amp;sysdate9..xlsx";</description>
      <pubDate>Thu, 20 Aug 2020 20:52:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-Read-Only-Excel-File-from-SAS/m-p/678268#M204692</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2020-08-20T20:52:19Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Read-Only Excel File from SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-Read-Only-Excel-File-from-SAS/m-p/678303#M204703</link>
      <description>&lt;P&gt;How does this work under windows? There are no&amp;nbsp;&lt;EM&gt;group&lt;/EM&gt;&amp;nbsp;and &lt;EM&gt;other&lt;/EM&gt; users.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 02:42:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-Read-Only-Excel-File-from-SAS/m-p/678303#M204703</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-08-21T02:42:29Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Read-Only Excel File from SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-Read-Only-Excel-File-from-SAS/m-p/678489#M204789</link>
      <description>&lt;P&gt;There are groups in Windows. I assume that OTHER is not the USER and not a GROUP where the USER belongs to. I have not played with this on Windows though. Here is the link to the &lt;A href="https://support.sas.com/documentation/cdl/en/hostwin/69955/HTML/default/chfnoptfmain.htm#p1m24anc2sxjp1n1futk0ekxn3to" target="_self"&gt;FILENAME PERMISSION= option&lt;/A&gt; documentation for Windows . &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 15:40:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-Read-Only-Excel-File-from-SAS/m-p/678489#M204789</guid>
      <dc:creator>LeonidBatkhan</dc:creator>
      <dc:date>2020-08-21T15:40:22Z</dc:date>
    </item>
  </channel>
</rss>

