'Can any of the SAS METADATA_GET* functions give information on authorizations
We use SAS in a client server setup with a metadata server. I use SAS Functions for Reading Metadata to read attributes and relations of SAS libraries, tables, folders etc from the metadata.
To verify our setup, we would like to list who can access what, i.e. to programmatically retrieve what you can find in SAS Management Console on the Authorization tab of an object's properties:

Does anyone know where to find that information?
For your inspiration: I usually use the functions to read metadata in a datastep, but this time, I used Lua
proc Lua restart;
submit;
debug = true
maxDo = 9
function getObjAttr(uri, attrList, old_obj)
new_obj = old_obj or {}
if debug then new_obj.uri = uri:gsub("%s+$", "") end
-- list only the requested attributes
local val_256 = string.rep("v",256)
for _, attrName in ipairs(attrList) do
if sas.METADATA_GETATTR(uri, attrName, val_256) >= 0 then
new_obj[attrName] =
( attrName:sub(1, 2) == 'Is'
or attrName == 'NumRows'
or attrName == 'UsageVersion' ) and tonumber(val_256)
or val_256:gsub("%s+$", ""):gsub("^%s+", "")
end
end
-- list all properties
local prop_256 = string.rep("p",256)
for prop_nr = 1, maxDo do
if sas.METADATA_GETNPRP(uri, prop_nr, prop_256, val_256) < 0 then break end
new_obj["_".. prop_256:gsub("%s+$", "")] = val_256:gsub("%s+$", "")
end
return new_obj
end
-- find the path to an object
function getLocation(uri)
local folder_256 = string.rep("f",256)
if sas.METADATA_GETNASN(uri,
string.find(uri, ":Tree") and 'ParentTree' or 'Trees',
1, folder_256) >= 0
then
return getObjAttr(folder_256, {'name'}, {location = getLocation(folder_256)})
end
end
-- collect all libraries
lib_set = {}
for obj_nr = 1, maxDo do
local uri_256 = string.rep("u",256)
-- test with a limited set
if sas.METADATA_GETNOBJ("SASLibrary?@name contains '_CBC'", obj_nr, uri_256) < 0 then break end
-- to get all, change to SASLibrary?@id contains '.'
lib_set[uri_256:gsub("%s+$", ""):gsub(".+%.", "")] =
getObjAttr(uri_256, {'name', 'libref', 'engine'}, {location = getLocation(uri_256)})
end
if debug then print("Lua: ".. table.tostring(lib_set)) end
-- to be completed with code to export the relevant info to sas datasets
endsubmit;
run;
Solution 1:[1]
I don't think this is possible in pure macro. However - it can be done with batch tools.
I started a PR to the core library that would make use of these - if you feel like finishing it off, be my guest! Our current SAS 9 environment does not have X Command so I can't test it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Allan Bowe |
