BookmarkSubscribeRSS Feed
Barite | Level 11

Dear All,


How can I delete registered tables from metadata library using sas code?


I know that using
 update_rule=(delete) within proc metalib procedure deletes the table if they no longer exists in the physical path

but i want to keep them in the physical path.



Tourmaline | Level 20

Even if I have never used it, I would be very surprised if PROC METALIB would delete any physical data.

Data never sleeps
Barite | Level 11

PROC METALIB does not delete the physical data but if the table exists in the physical path it does not remove it from

the metadata library .


For wxample , I have library test defined in metadata with the following properties:

 - location /Shared Data

 - selected items - /path/test


I have registered the table class in this library and now I want to delete it from the library but still keep it in the /path/test .


how can I do it?


You can easily delete a registered table in SAS Management Console without affecting the physical original. 

Barite | Level 11

I know but it is not a choice. We have many libraries and a lot of tables registered in each of them.

We need a programming approach.


What about going through the entire library using an EXCLUDE statement to not process the tables you do not want registered?


proc metalib;
     omr (libid="XXXXXXX");
  exclude table1 table2......;

Personally I avoid registering tables in metadata where possible so I don't have these administration problems Smiley Happy

Fluorite | Level 6

I'm bumping this question since I have the same problem.


I've seen this workaround:

* Rename the physical table

* Run metalib (will delete metadata table because physical table has another name)

* Rename the physical table to original name.


The workaround doesn't work for me since the physical table is stored in Hadoop and those tables can not be renamed (at least not with proc datasetes).

Fluorite | Level 6

Quick and dirty solution


data _null_;
	length uri $256 ;
	call missing(uri, nobj);

	* Get URI for table I want to delete	;

	* Delete table	;

	* Output for debug purposes ;
	put nobj= rc=;

Be careful!

This solution will delete the first table found named "stg_DT_HJARTA". Not all tables named "stg_DT_HJARTA".

There is no error handling. The code will not give ERRORs or WARNINGs if it fails.


If someone knows the syntax for specyfing the folder path in the query, I'd apriciate it. I'ld like something like this:

nobj=metadata_getnobj("omsobj:DataTable?@Name='stg_DT_HJARTA' and @path='/Shared Data/Project XYZ'",1,uri);


Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.


Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 1 like
  • 4 in conversation