DATA Step, Macro, Functions and more

Create a Owner Listing by Dataset for a SAS Library

Reply
New Contributor
Posts: 3

Create a Owner Listing by Dataset for a SAS Library

I am trying to manage numerous datasets for our department.

I want to create an output view that will show the primary owner of each dataset within a particular sas library.

Output Example:

Dataset     Owner

abcde        smith123

fghijk          lewis456

It sounds simple but I cannot come up with a solution to produce this type of information.

Thoughts?

PROC Star
Posts: 1,231

Re: Create a Owner Listing by Dataset for a SAS Library

What do you mean by "Primary Owner"?

Do you mean at the OS level, the account which is the owner of each file?

What OS?

New Contributor
Posts: 3

Re: Create a Owner Listing by Dataset for a SAS Library

Primary Owner would be defined as the person that created the dataset.

OS system is windows.

Super User
Posts: 5,256

Re: Create a Owner Listing by Dataset for a SAS Library

Independent of OS, there are tools that can make directory listing with a variety of attributes per file/directory. Have that listing stored in a text file, and then import it to SAS for further analysis/reporting.

Data never sleeps
New Contributor
Posts: 3

Re: Create a Owner Listing by Dataset for a SAS Library

I was wondering if this type of request was going to take a separate tool or solution outside of SAS. I was hoping to run some code within SAS to create this level of information.

Super User
Posts: 5,256

Re: Create a Owner Listing by Dataset for a SAS Library

No, I don't think that there is support in SAS language to retrieve this information.

However, if you create a DOS script, or similar, that creates this information, you can trigger that script from SAS (X statement, call system() etc).

Data never sleeps
PROC Star
Posts: 1,231

Re: Create a Owner Listing by Dataset for a SAS Library

I would search lexjansen.com for relevant papers.

Looks like this one had a couple different ways for finding file owner (written for unix, but would think similar approach should work with windows).

support.sas.com/resources/papers/proceedings13/414-2013.pdf

Super Contributor
Posts: 644

Re: Create a Owner Listing by Dataset for a SAS Library

The /Q option on the DOS dir command gives the owner of the file.  You could use X or equivalent to issue the DOS command to write the contents to a text file, then import the file into SAS.  Something like

dir [drive:][path] /Q /N /S > c:\temp\File_List.txt

where /N puts the filename last (easier to read into SAS) and /S allows subdirectories to be listed

However, if you use /S you will have to write code to extract the subdirectory information from the header for each directory.

Richard


Valued Guide
Posts: 2,175

Re: Create a Owner Listing by Dataset for a SAS Library

I

adapt the idea from in a data step like

data dir_list ;

infile "dir ""%path(work)"" /Q /N /S" device=pipe lrecl=1000 truncover ;

input; list ;

run;

naturally in WORK, all files are owned by the user.

If you want to adapt this for any SAS library. then remove that /S as a SAS library tends to be just on the one level.

here is my SASlog

NOTE: The infile "dir ""C:\Users\PCUSER~1\AppData\Local\Temp\SAS Temporary Files\_TD4232_PCUSER-PC_"" /Q /N /S" is:

      Unnamed Pipe Access Device,

      PROCESS=dir "C:\Users\PCUSER~1\AppData\Local\Temp\SAS Temporary Files\_TD4232_PCUSER-PC_" /Q /N /S,

      RECFM=V,LRECL=1000

RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0

1          Volume in drive C has no label. 32

2          Volume Serial Number is A0FC-315E 34

3          0

4          Directory of C:\Users\PCUSER~1\AppData\Local\Temp\SAS Temporary Files\_TD4232_PCUSER-PC_ 89

5          0

6         22/01/2014  07:26    <DIR>          PCuser-PC\PC user      . 60

7         22/01/2014  07:26    <DIR>          BUILTIN\Administrators .. 61

8         22/01/2014  07:26                 0 PCuser-PC\PC user      dir_list.sas7bdat.lck 80

9         22/01/2014  07:26            39,987 PCuser-PC\PC user      sashtml.htm 70

10        22/01/2014  07:25             5,120 PCuser-PC\PC user      sasmacr.sas7bcat 75

11        22/01/2014  07:24             1,409 PCuser-PC\PC user      SASMONO.FOT 70

12        22/01/2014  07:24             1,409 PCuser-PC\PC user      SASMONOB.FOT 71

13        22/01/2014  07:24            97,792 PCuser-PC\PC user      sastmp-000000001.sas7bitm 84

14        22/01/2014  07:26            97,792 PCuser-PC\PC user      sastmp-000000002.sas7bitm 84

15        22/01/2014  07:24               512 PCuser-PC\PC user      sastmp-000000003.sas7butl 84

16                       8 File(s)        244,021 bytes 45

17         0

18             Total Files Listed: 24

19                       8 File(s)        244,021 bytes 45

20                       2 Dir(s)  18,735,345,664 bytes free 50

NOTE: 20 records were read from the infile "dir ""C:\Users\PCUSER~1\AppData\Local\Temp\SAS Temporary Files\_TD4232_PCUSER-PC_"" /Q /N /S".

      The minimum record length was 0.

      The maximum record length was 89.

NOTE: The data set WORK.DIR_LIST has 20 observations and 0 variables.

NOTE: DATA statement used (Total process time):

      real time           0.08 seconds

      cpu time            0.03 seconds



On Windows platforms, you might want to try the ideas using the Windows 32bit API proposed by Richard DeVenezia at http://www.devenezia.com/downloads/sas/sascbtbl/GetSetFileAttributesA.sas



peterC

Super User
Super User
Posts: 6,499

Re: Create a Owner Listing by Dataset for a SAS Library

Owner is not one of the values available with the FINFO() function.  You can see it in the printed output from PROC CONTENTS on Unix hosts, so you could retrieve it using ODS OUTPUT statements.  But it is not printed on Windows hosts.

Ask a Question
Discussion stats
  • 9 replies
  • 973 views
  • 0 likes
  • 6 in conversation