I am writing a deployment script, and would like to programmatically register a simple (and empty) BASE library, such as the one below, in Metadata.
libname MYLIB 'C:\temp';
Sample XML syntax can be found here.. Am just not sure how to combine that with proc metadata to perform the update (eg how do the metadata ID's get generated?)
@user2173800 Did u ever recieve a solution to the question above? Here is what i came up with :
The below Code creates a SAS Library called BASE_Metalib under the Metadata folder :/Shared Data/Libraries/BASE_Metalib (this folder is assumed to already exist in Metadata). The code also resgisters all tables under this Directory defined for this Library. The below code uses Metadata Datastep functions to Interface with metadata.
/*Creating a Metadata Library with BASE Engine and register all the tables under it */
options metaserver="taasasf2"
metaport=8561
metauser="testuser"
metapass="test123"
metarepository="Foundation";
%Let MetaLibName=BASE_Metalib; /* Name of the SAS Library with BASE Engine to be created */
data _null_;
length luri uri muri $256;
rc=0;
Call missing(luri,uri,muri);
/* Create a SASLibrary object in the Shared Data folder. */
rc=metadata_newobj("SASLibrary",
luri,
"&MetaLibname.",
"Foundation",
"omsobj:Tree?@Name=%bquote('&Metalibname.')",
"Members");
put rc=;
put luri=;
/* Add PublicType,UsageVersion,Engine,Libref,IsDBMSLibname attribute values. */
rc=metadata_setattr(luri,
"PublicType",
"Library");
put rc=;
put luri=;
rc=metadata_setattr(luri,
"UsageVersion",
"1000000.0");
put rc=;
put luri=;
rc=metadata_setattr(luri,
"Engine",
"BASE");
put rc=;
put luri=;
rc=metadata_setattr(luri,
"Libref",
"SASTEST");
put rc=;
put luri=;
rc=metadata_setattr(luri,
"IsDBMSLibname",
"0");
put rc=;
put luri=;
/* Set Directory Object via UsingPackages Association for the SAS Library Object */
rc=metadata_newobj("Directory",
uri,
"");
put uri=;
rc=metadata_setassn(luri,
"UsingPackages",
"Replace",
uri);
put rc=;
rc=metadata_setattr(uri,"DirectoryName","/shrproj/files/ANA_AR2_UWCRQ/data");
put rc=;
/* Set Server Context Object via DeployedComponents Association for the SAS Library Object */
rc=metadata_getnobj("omsobj:ServerContext?@Name='SASApp'",1,muri);
put muri=;
rc=metadata_setassn(luri,
"DeployedComponents",
"Append",
muri);
put rc=;
Run;
proc metalib;
omr (library="&Metalibname.");
report;
run;