BookmarkSubscribeRSS Feed
bdubb
Calcite | Level 5

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?

9 REPLIES 9
Quentin
Super User

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?

BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
bdubb
Calcite | Level 5

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

OS system is windows.

LinusH
Tourmaline | Level 20

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
bdubb
Calcite | Level 5

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.

LinusH
Tourmaline | Level 20

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
Quentin
Super User

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

BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
RichardinOz
Quartz | Level 8

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


Peter_C
Rhodochrosite | Level 12

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

Tom
Super User Tom
Super User

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 9 replies
  • 3460 views
  • 0 likes
  • 6 in conversation