BookmarkSubscribeRSS Feed
sakurugoda
Fluorite | Level 6

Due to a requirement in creating multiple SAS libraries from time to time in the Management Console, I am trying to figure out how to do this programmatically.  These libraries are pointing to external databases. So far, using the available examples I was able to use the following code to create library metadata. SAS Version 9.4M6.

 

proc metadata in='<AddMetadata>
 <Metadata>
   <SASLibrary
      Name="Test Library" 
      Desc="This is a test" 
      Folder="\Shared Data\Test"
      Engine="DB2"    
      IsDBMSLibname="1"      
      IsHidden="0"
      Libref="testlib"
      IsPreassigned="0"
      PublicType="Library">
    </SASLibrary>
 </Metadata>
 <Reposid>A0000001.A849HGWS</Reposid>
 <NS>SAS</NS>
 <Flags>268435456</Flags>
 <Options/>
</AddMetadata>
';


However this is still missing the resource template, schema name, location (folder name). Is there any way we can add these programmatically as well? Also anyway to update the access templates? Any attributes that I can assign these values to when calling proc metadata? Thanks in advance.

1 REPLY 1
AllanBowe
Barite | Level 11
This macro will create a BASE engine library - I'm sure it could be extended to support other engine types: https://core.sasjs.io/mm__createlibrary_8sas.html

If you manage it, feel free to raise a PR!

By the way we also have a free metadata exploration tool, if you'd like a copy just send a PM.
/Allan
MacroCore library for app developers
Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 875 views
  • 0 likes
  • 2 in conversation