The script itself generates the necessary XML files for `PROC METADATA` via DATA `_NULL_` steps and does not use external data.
1 Code Block
DATA STEP
Explanation : Checks for the library's existence in the metadata server using the `metadata_resolve` function with the provided name as a parameter. Retrieves the object's URI and type.
Copied!
data _null_;
length type uri $256;
rc=metadata_resolve("omsobj:SASLibrary? @Name='&name'",type,uri);
call symputx('checktype',type,'l');
call symputx('liburi',uri,'l');
putlog (_all_)(=);
run;
Explanation : Generates the XML request file for the `DeleteMetadata` action. This temporary file contains the deletion instruction targeting the previously identified library URI.
Copied!
filename &fname1 temp lrecl=10000;
filename &fname2 temp lrecl=10000;
data _null_ ;
file &fname1 ;
put "<DeleteMetadata><Metadata><SASLibrary Id='&liburi'/>";
put "</Metadata><NS>SAS</NS><Flags>268436480</Flags><Options/>";
put "</DeleteMetadata>";
run ;
1
filename &fname1 temp lrecl=10000;
2
filename &fname2 temp lrecl=10000;
3
DATA _null_ ;
4
file &fname1 ;
5
put "<DeleteMetadata><Metadata><SASLibrary Id='&liburi'/>";
6
put "</Metadata><NS>SAS</NS><Flags>268436480</Flags><Options/>";
7
put "</DeleteMetadata>";
8
RUN ;
3 Code Block
PROC METADATA
Explanation : Executes the `PROC METADATA` procedure to send the generated XML request to the metadata server and perform the deletion.
Copied!
proc metadata in=&fname1 out=&fname2 verbose;run;
1
PROC METADATA in=&fname1 out=&fname2 verbose;RUN;
4 Code Block
DATA STEP
Explanation : Verifies post-execution if the library still exists by re-querying the metadata server with the URI. The result is stored in the `isgone` macro variable.
Copied!
data _null_;
length type uri $256;
call missing (of _all_);
rc=metadata_resolve("omsobj:SASLibrary? @Id='&liburi'",type,uri);
call symputx('isgone',type,'l');
run;
Explanation : Calls the `%mp_abort` utility macro to stop execution and report an error if the library is still detected (deletion failure).
Copied!
%mp_abort(iftrue=(&isgone = SASLibrary)
,mac=&sysmacroname
,msg=%str(Library (&name) NOT deleted)
)
1
%mp_abort(iftrue=(&isgone = SASLibrary)
2
,mac=&sysmacroname
3
,msg=%str(Library (&name) NOT deleted)
4
)
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
« It is vital to remember that this process only removes the logical definition of the library from the SAS Metadata Server. It does not delete the physical .sas7bdat files from the file system or the schemas from the external database (e.g., Oracle or SQL Server). »
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.