In a UNIX operating environment, there are several ways to obtain the owner information for a SAS® data set:
1. Specify the path to the SAS library when you invoke the macro. The variable USER_ID holds the user id of the owner of the data set.
%macro file_info(root=/);
filename inf pipe "ls -l &root" Lrecl=200;
data file_info (drop= txt) ;
infile inf lrecl=200 truncover ;
input txt $char200. ;
if index(txt,'>') >=1 or index(txt,'<') >=1 then delete ;
user_id=scan(txt,3,' ') ;
run;
%mend file_info;
%file_info(root=$HOME);
2. The ODS OUTPUT statement creates an output data set that contains the Engine Host information from PROC CONTENTS.
/* replace $HOME with the path to the directory you want to check */
libname read '$HOME';
ods output Contents.DataSet.EngineHost=tt ;
proc contents data=read._all_ out=test details /*(keep=libname memname)*/ ;
run ;
data owners ;
set tt (where=(Label1="Owner Name")) ;
run ;
3. Use a series of functions to obtain the information found in the array
variables.
filename home "$HOME" ;
data ttt (keep=fname ownername groupname permissions lastmodified size) ;
array foo (6) $50 fname ownername groupname permissions lastmodified
size;
dd=dopen('home') ;
if dd>0 then do ;
memcount=dnum(dd);
do m=1 to memcount ;
lstname=dread(dd,m);
rc=filename('abc',lstname);
fid=fopen('abc');
if fid>0 then do ;
infonum=foptnum(fid);
do i=1 to infonum;
infoname=foptname(fid,i);
infoval=finfo(fid,infoname);
foo=finfo(fid,infoname);
end;
output;
close=fclose(fid);
end ;
end ;
cc=dclose(dd) ;
end ;
run ;