BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
cfrey73
Fluorite | Level 6

I am looking to grab the owner of each table in a shared library and output the table and owner into a dataset so that we can use it to audit. I have looked into the proc contents procedure, which looks like it can get you the owner, but I don't see any way to get that into a table using either the out or out2 statements. Any help would be useful

proc contents data = lib._ALL_ memtype=data out=out_data; 
run;
1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

I'm not sure that Owner is always the same as "who created it", but if you need the OS owner field for each table you could try this with PROC DATASETS -- using the same ODS TRACE/OUTPUT technique.

 

ods trace on;
ods output EngineHost=WithOwner;
proc datasets lib=sashelp;
 contents data=_ALL_;
quit;

data WithOwner;
 set WithOwner (where=(label1 in ('Filename' 'Owner Name')));
run;

View solution in original post

8 REPLIES 8
ChrisHemedinger
Community Manager

Using ODS TRACE, you can find the table names of the output you see in the ODS destination.

 

ods trace on;

LOG: 

Output Added:
-------------
Name:       Directory
Label:      Directory Information
Template:   Base.Datasets.Directory
Path:       Contents.Directory

From this, you can use ODS OUTPUT to add this table to your output data sets.

 

ods output directory=withowner;
proc contents data = sashelp._ALL_ memtype=data out=out_data; 
run;

The WITHOWNER table will contain what you need.

cfrey73
Fluorite | Level 6

Thanks, it looks like this gives the owner of the directory, is there another command to get the owner/creator  of each individual dataset within the directory, or even just to get a single table and I could write a loop over the directory.

cfrey73
Fluorite | Level 6
I checked there, didn't see anything about who created the table
ChrisHemedinger
Community Manager

I'm not sure that Owner is always the same as "who created it", but if you need the OS owner field for each table you could try this with PROC DATASETS -- using the same ODS TRACE/OUTPUT technique.

 

ods trace on;
ods output EngineHost=WithOwner;
proc datasets lib=sashelp;
 contents data=_ALL_;
quit;

data WithOwner;
 set WithOwner (where=(label1 in ('Filename' 'Owner Name')));
run;
cfrey73
Fluorite | Level 6
thanks chris! your solution was exactly what I was looking for.
Reeza
Super User
What's your OS?
You can use FINFO functions but if you have XCMD enabled you can also query it from the OS commands
cfrey73
Fluorite | Level 6
Operating inside of a virtual environment set up by CMS, which is running 7, unfortuanlty they limit our permissions to do basically anything useful, so it has to be limited to stuff I can query in SAS EG, and they have also disabled x commands so I can't go that route

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 8 replies
  • 7791 views
  • 7 likes
  • 3 in conversation