- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You can use FINFO functions but if you have XCMD enabled you can also query it from the OS commands
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content