BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
paul_e
Obsidian | Level 7

Hello, I'd like to automatically assign libraries from metadata with a code snippet. Retrieving the info including libname and physical location is the easy part, so I had though I could just write a libname statment and paste the correct info from metadata with macro variables. However, when I try this I get the following errors:

 

ERROR: Encountered error when the V9 engine tried to determine if MYLIB has a registered secured library object location.
ERROR: User does not have appropriate authorization level for library MYLIB.
ERROR: Error in the LIBNAME statement.
ERROR: Libref MYLIB is not assigned.

So it seems I'm not allowed to assign libraries that already sit as unassigned in the metadata. Assigning them manually in EG from the server menu works fine, so this is not an actual authorization problem.

 

Is there any way to get around this? Maybe there's a piece of metadata code to assign a library from metadata?

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

The libname meta engine allows you to assign a library that uses a libname definition from SAS Metadata.

 

Here a sample as used in an actual implementation:

libname pg_temp meta liburi="SASLibrary?@libref='pg_temp'" metaout=data;

SASLibrary?@libref='pg_temp'" searches through metadata library object and will use the one where the libref property has the value pg_temp. 

 

In below sample the libref that gets assigned libname pg_temp will have the same libref like the one defined in SAS metadata @libref='pg_temp'" that gets used to define the library. This gives you a result pretty much the same as if the library would have been defined as pre-assigned in SAS metadata.

 

Now.... metadata bound libraries are something special and I'm not sure if above syntax will also work for them. But it's your best shot so just try it.

 

View solution in original post

4 REPLIES 4
SASJedi
SAS Super FREQ

It would be useful to share the code that generated this error...

Check out my Jedi SAS Tricks for SAS Users
LinusH
Tourmaline | Level 20
Is there a reqason why you don't assign it from the server context/metadata server?
What happens if you try the meta libname engine?
Data never sleeps
AhmedAl_Attar
Rhodochrosite | Level 12

Hi @paul_e 

I would highly encourage you to read the following papers and article, if you have not already

A Framework for Using the SAS® Metadata Server from SAS® Foundation

A Programming Approach to Implementing SAS® Metadata-Bound Libraries for SAS® Data Set Encryption

A Metadata to Physical Table Comparison Tool

Using Dynamic Views as a Supplement to SAS Security to Enhance Multiple Levels of Access Requirement... 

SAS administrator tip: How to identify and prevent duplicate librefs in SAS metadata

 

These may not provide you straight answer to you issue, but I hope they will provide you with wider perspective on what's involved with libraries defined in the Metadata Server.

Patrick
Opal | Level 21

The libname meta engine allows you to assign a library that uses a libname definition from SAS Metadata.

 

Here a sample as used in an actual implementation:

libname pg_temp meta liburi="SASLibrary?@libref='pg_temp'" metaout=data;

SASLibrary?@libref='pg_temp'" searches through metadata library object and will use the one where the libref property has the value pg_temp. 

 

In below sample the libref that gets assigned libname pg_temp will have the same libref like the one defined in SAS metadata @libref='pg_temp'" that gets used to define the library. This gives you a result pretty much the same as if the library would have been defined as pre-assigned in SAS metadata.

 

Now.... metadata bound libraries are something special and I'm not sure if above syntax will also work for them. But it's your best shot so just try it.

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 4 replies
  • 417 views
  • 5 likes
  • 5 in conversation