Update Table Metadata Using Base SAS Code
Ever had the need to update table metadata by submitting SAS code? If so, you can use PROC METALIB to do so. This may be useful if you want to automate an ETL process, which loads tables and registers in metadata at the same time.
Update Existing Table in SAS Metadata
The following code connects to a SAS library already registered in metadata and updates the table definition. The update_rule option specifies that if the table does not physically exist anymore, delete it from metadata. Important note: you must have ReadMetadata and WriteMetadata permissions on the table object, which are assigned by your SAS administrator.
proc metalib; omr (library="[INSERT METADATA LIBRARY NAME HERE]" metarepository="Foundation"); select("[INSERT TABLE NAME HERE]"); update_rule=(delete); report; run;
Doing More with PROC METALIB
You can do other useful things with this procedure, such as update metadata for all physical tables in a library. To do this simply remove the select option.
SAS Support has additional information and options you can use within PROC METALIB to do even more with table metadata. The update_rule option has a few interesting options as well as the select option.
The standard way to update table metadata is through SAS Management Console. This technique allows you to take a more programmatic approach if necessary.
Have fun making your code a little more automagic!