<?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: Looking for a macro that converts unix file permissions string to a number in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Looking-for-a-macro-that-converts-unix-file-permissions-string/m-p/337230#M271440</link>
    <description>Hi Shmuel,&lt;BR /&gt;&lt;BR /&gt;How to handle Sticky Bits, UID &amp;amp; GID's with this code? Thanks your guidance.</description>
    <pubDate>Thu, 02 Mar 2017 04:07:38 GMT</pubDate>
    <dc:creator>aj34321</dc:creator>
    <dc:date>2017-03-02T04:07:38Z</dc:date>
    <item>
      <title>Looking for a macro that converts unix file permissions string to a number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looking-for-a-macro-that-converts-unix-file-permissions-string/m-p/325540#M271436</link>
      <description>&lt;P&gt;Looking for a macro that converts unix file permissions string to a number&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Like -&lt;/P&gt;
&lt;P&gt;-rwxr-xr-x &amp;nbsp; &amp;nbsp;should return 755&lt;/P&gt;
&lt;P&gt;-rwxrwxr-x &amp;nbsp; should retrun 775&lt;/P&gt;
&lt;P&gt;-rwx------ &amp;nbsp; &amp;nbsp; should return 700&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Has anyone something like this readily available?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Rgds, Anil&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2017 02:11:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looking-for-a-macro-that-converts-unix-file-permissions-string/m-p/325540#M271436</guid>
      <dc:creator>aj34321</dc:creator>
      <dc:date>2017-01-18T02:11:40Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for a macro that converts unix file permissions string to a number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looking-for-a-macro-that-converts-unix-file-permissions-string/m-p/325545#M271437</link>
      <description>&lt;P&gt;data perm;&lt;BR /&gt; input perm $10.;&lt;BR /&gt; array vn v1-v9;&lt;BR /&gt; do i=1 to 9;&lt;BR /&gt; j=i+1;&lt;BR /&gt; x=substr(perm,j,1);&lt;BR /&gt; if x='-' then vn(i) =0; else&lt;BR /&gt; if x='r' then vn(i) =4; else&lt;BR /&gt; if x='w' then vn(i) =2; else&lt;BR /&gt; if x='x' then vn(i) =1;&lt;BR /&gt;end;&lt;BR /&gt;code=(v1+v2+v3)*100+(v4+v5+v6)*10+v7+v8+v9;&lt;BR /&gt;keep perm code; &lt;BR /&gt;cards;&lt;BR /&gt;-rwxr-xr-x&lt;BR /&gt;-rwxrwxr-x&lt;BR /&gt;-rwx------&lt;BR /&gt;; run;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2017 02:40:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looking-for-a-macro-that-converts-unix-file-permissions-string/m-p/325545#M271437</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-01-18T02:40:42Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for a macro that converts unix file permissions string to a number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looking-for-a-macro-that-converts-unix-file-permissions-string/m-p/325574#M271438</link>
      <description>&lt;P&gt;Use the stat command for files:&lt;/P&gt;
&lt;PRE&gt;stat -c "%a %n" filename&lt;/PRE&gt;
&lt;P&gt;on Linux. It delivers the permissions in numerical form, followed by the filename.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2017 07:48:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looking-for-a-macro-that-converts-unix-file-permissions-string/m-p/325574#M271438</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-01-18T07:48:31Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for a macro that converts unix file permissions string to a number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looking-for-a-macro-that-converts-unix-file-permissions-string/m-p/325589#M271439</link>
      <description>Thank you so much.  This small code really awesome.</description>
      <pubDate>Wed, 18 Jan 2017 09:09:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looking-for-a-macro-that-converts-unix-file-permissions-string/m-p/325589#M271439</guid>
      <dc:creator>aj34321</dc:creator>
      <dc:date>2017-01-18T09:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for a macro that converts unix file permissions string to a number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looking-for-a-macro-that-converts-unix-file-permissions-string/m-p/337230#M271440</link>
      <description>Hi Shmuel,&lt;BR /&gt;&lt;BR /&gt;How to handle Sticky Bits, UID &amp;amp; GID's with this code? Thanks your guidance.</description>
      <pubDate>Thu, 02 Mar 2017 04:07:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looking-for-a-macro-that-converts-unix-file-permissions-string/m-p/337230#M271440</guid>
      <dc:creator>aj34321</dc:creator>
      <dc:date>2017-03-02T04:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for a macro that converts unix file permissions string to a number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looking-for-a-macro-that-converts-unix-file-permissions-string/m-p/337277#M271441</link>
      <description>&lt;P&gt;The sticky bits occupy a different position in the octal value:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data perm (keep=perm perms_oct);&lt;BR /&gt;input perm $10.;&lt;BR /&gt;perms_oct = 0;&lt;BR /&gt;do i = 0 to 2;&lt;BR /&gt;&amp;nbsp; read = (substr(perm,i*3+2,1)='r');&lt;BR /&gt;&amp;nbsp; write = (substr(perm,i*3+3,1)='w');&lt;BR /&gt;&amp;nbsp; exec = (substr(perm,i*3+4,1) in ('x','s'));&lt;BR /&gt;&amp;nbsp; setb = (substr(perm,i*3+4,1) in ('S','s'));&lt;BR /&gt;&amp;nbsp; i1 = abs(i - 2);&lt;BR /&gt;&amp;nbsp; oct = read * 4 + write * 2 + exec * 1;&lt;BR /&gt;&amp;nbsp; if oct ne 0 then perms_oct = perms_oct + oct * 8 ** i1;&lt;BR /&gt;&amp;nbsp; if setb ne 0 then perms_oct = perms_oct + (((setb*2) ** i) * 512);&lt;BR /&gt;end;&lt;BR /&gt;format perms_oct octal4.;&lt;BR /&gt;cards;&lt;BR /&gt;-rwxr-xr-x&lt;BR /&gt;-rwxrwxr-x&lt;BR /&gt;-rwx------&lt;BR /&gt;-rwsr-sr-x&lt;BR /&gt;---------S&lt;BR /&gt;;&lt;BR /&gt;run;

proc print data=perm noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;result looks like this:&lt;/P&gt;
&lt;PRE&gt;              perms_
   perm        oct

-rwxr-xr-x     0755 
-rwxrwxr-x     0775 
-rwx------     0700 
-rwsr-sr-x     3755 
---------S     4000 
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Edit: slightly changed my code to accomodate the fact that the SAS ** operator doesn't like 0 ** 0.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2017 10:03:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looking-for-a-macro-that-converts-unix-file-permissions-string/m-p/337277#M271441</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-03-02T10:03:01Z</dc:date>
    </item>
  </channel>
</rss>

