<?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 get the owner and group for all the pathNfilename listed in a dataset in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-get-the-owner-and-group-for-all-the-pathNfilename-listed/m-p/731121#M38480</link>
    <description>&lt;P&gt;Use a "dynamic pipe":&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA Info;
length PathNFileName $ 150;
INFILE DATALINES ;
INPUT PathNFileName &amp;amp; $ ;
DATALINES;
/path1/filename1
/path1/filename2
/path1/filename3
/path2/filename4
/path3/filename5
;

data ownership;
set info;
length fvar $200;
fvar = 'ls -l ' !! PathNFileName;
infile dummy pipe filevar=fvar;
input perms :$20. links owner :$20. group :$20.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But for this particular issue, you may be better off using the built-in file functions.&lt;/P&gt;</description>
    <pubDate>Sat, 03 Apr 2021 10:25:45 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-04-03T10:25:45Z</dc:date>
    <item>
      <title>How to get the owner and group for all the pathNfilename listed in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-get-the-owner-and-group-for-all-the-pathNfilename-listed/m-p/731033#M38473</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I am using the following macro to get the owner and group and individually, it works well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro ReadOwnerNGroup(pathNfileName);&lt;BR /&gt;data _null_;&lt;BR /&gt;infile "ls -l '&amp;amp;pathNfileName.'" pipe;&lt;BR /&gt;input perms :$20. links owner :$20. group :$20.;&lt;BR /&gt;call symputx("owner",owner,'G');&lt;BR /&gt;call symputx("group",group,'G');&lt;BR /&gt;run;&lt;BR /&gt;%mend ReadOwnerNGroup;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then I provide a dataset containing three different path and filename like below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*the real info about path and filename are replaced for safety purpose*/&lt;BR /&gt;DATA Info;&lt;BR /&gt;length PathNFileName $ 150;&lt;BR /&gt;INFILE DATALINES ;&lt;BR /&gt;INPUT PathNFileName &amp;amp; $ ;&lt;BR /&gt;DATALINES;&lt;BR /&gt;/path1/filename1&lt;BR /&gt;/path1/filename2&lt;BR /&gt;/path1/filename3&lt;BR /&gt;/path2/filename4&lt;BR /&gt;/path3/filename5&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then I calculate the number of obs;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql noprint;&lt;BR /&gt;%global nobs;&lt;BR /&gt;select count(*) into: nobs&lt;BR /&gt;from info;&lt;BR /&gt;quit;&lt;BR /&gt;%put &amp;amp;nobs;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then I am trying to gather all the information but I think I always getting the owner and the group of the last records.&lt;/P&gt;
&lt;P&gt;Is there a way to solve that issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data info2;&lt;BR /&gt;do Slice=1 to &amp;amp;nobs.;&lt;BR /&gt;set info point=Slice;&lt;BR /&gt;call execute('%nrstr(%ReadOwnerNGroup('!!(pathNfileName)!!'));'); &lt;BR /&gt;Owner=symget('owner');&lt;BR /&gt;Group=symget('group');&lt;BR /&gt;output; &lt;BR /&gt;end; &lt;BR /&gt;stop;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Apr 2021 19:29:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-get-the-owner-and-group-for-all-the-pathNfilename-listed/m-p/731033#M38473</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2021-04-02T19:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the owner and group for all the pathNfilename listed in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-get-the-owner-and-group-for-all-the-pathNfilename-listed/m-p/731067#M38477</link>
      <description>&lt;P&gt;You've got a timing issue. call execute() gets stacked and only executes once your data step iterated through all the rows. Using the dosubl() function instead should get you around this issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An alternative and likely easier way would be to use the filename() function together with the &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=hostunx&amp;amp;docsetTarget=p0rtd85lrdft6en1mhzqfbp55fv4.htm&amp;amp;locale=en" target="_self"&gt;finifo()&lt;/A&gt; function. The docu for finfo() provides a&amp;nbsp;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=hostunx&amp;amp;docsetTarget=n0bxwkpflam4xun1wfhym8edfi59.htm&amp;amp;locale=en#n0nnegdsicoshzn1lklzpbwuzxey" target="_self"&gt;link to an example&lt;/A&gt; which is already very close to what you're trying to achieve.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Apr 2021 22:02:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-get-the-owner-and-group-for-all-the-pathNfilename-listed/m-p/731067#M38477</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-04-02T22:02:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the owner and group for all the pathNfilename listed in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-get-the-owner-and-group-for-all-the-pathNfilename-listed/m-p/731121#M38480</link>
      <description>&lt;P&gt;Use a "dynamic pipe":&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA Info;
length PathNFileName $ 150;
INFILE DATALINES ;
INPUT PathNFileName &amp;amp; $ ;
DATALINES;
/path1/filename1
/path1/filename2
/path1/filename3
/path2/filename4
/path3/filename5
;

data ownership;
set info;
length fvar $200;
fvar = 'ls -l ' !! PathNFileName;
infile dummy pipe filevar=fvar;
input perms :$20. links owner :$20. group :$20.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But for this particular issue, you may be better off using the built-in file functions.&lt;/P&gt;</description>
      <pubDate>Sat, 03 Apr 2021 10:25:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-get-the-owner-and-group-for-all-the-pathNfilename-listed/m-p/731121#M38480</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-04-03T10:25:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the owner and group for all the pathNfilename listed in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-get-the-owner-and-group-for-all-the-pathNfilename-listed/m-p/731125#M38481</link>
      <description>We are close to a good solution.  The only issue that I have it is when we have a space into the path or the filename it does not work.</description>
      <pubDate>Sat, 03 Apr 2021 11:22:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-get-the-owner-and-group-for-all-the-pathNfilename-listed/m-p/731125#M38481</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2021-04-03T11:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the owner and group for all the pathNfilename listed in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-get-the-owner-and-group-for-all-the-pathNfilename-listed/m-p/731127#M38482</link>
      <description>&lt;P&gt;Expand the assignment of the fvar variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;fvar = 'ls -l ' !! quote(strip(PathNFileName),"'");&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And there's a reason for Maxim 44. Those blanks serve no purpose that can't be solved with underlines and only cause extra work.&lt;/P&gt;</description>
      <pubDate>Sat, 03 Apr 2021 11:50:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-get-the-owner-and-group-for-all-the-pathNfilename-listed/m-p/731127#M38482</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-04-03T11:50:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the owner and group for all the pathNfilename listed in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-get-the-owner-and-group-for-all-the-pathNfilename-listed/m-p/731164#M38483</link>
      <description>&lt;P&gt;No need to use macro code. Also if any of those filenames are directories your code will blow up.&amp;nbsp; Include -d option to the ls command.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Info;
  infile datalines truncover ;
  input PathNFileName $256. ;
DATALINES;
/path1/filename1
/path1/file name 2
/path1/filename3
/path2/filename4
/path3/filename5
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data info2;
  set info;
  length cmd $300;
  cmd = catx(' ','ls -ld',quote(trim(pathnfilename)));
  infile cmd pipe filevar=cmd truncover ;
  input perms :$20. links owner :$20. group :$20.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Apr 2021 17:06:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-get-the-owner-and-group-for-all-the-pathNfilename-listed/m-p/731164#M38483</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-03T17:06:48Z</dc:date>
    </item>
  </channel>
</rss>

