SUPPORT / SAMPLES & SAS NOTES
 

Support

Usage Note 42606: Obtain the creator of a SAS data set in a UNIX operating environment

DetailsAboutRate It

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 data 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 ;



Operating System and Release Information

Product FamilyProductSystemSAS Release
ReportedFixed*
SAS SystemBase SAS64-bit Enabled AIX9.1 TS1M0
64-bit Enabled HP-UX9.1 TS1M0
64-bit Enabled Solaris9.1 TS1M0
HP-UX IPF9.1 TS1M0
Linux9.1 TS1M0
OpenVMS Alpha9.1 TS1M0
Tru64 UNIX9.1 TS1M0
* For software releases that are not yet generally available, the Fixed Release is the software release in which the problem is planned to be fixed.