BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
klroesner
Obsidian | Level 7

 

Hello World!

I create over 600 ODBC SASLibraries with this macro:

 

%macro create_odbc_lib (MetaLibName=, Desc=, LibRefName=, FolderPath=, DatabaseSchema=, Connection= , AssignMode= , folderTab=, cntrlTab= );

...

	data temp;
		length luri uri muri lcuri puri euri  propuri1-propuri7 $256 rc1-rc46 8;
		
		Call missing(luri, uri, muri, lcuri, puri, euri,propuri1,propuri2,propuri3,propuri4,propuri5,propuri6,propuri7);

		/* Create a SASLibrary object in the Shared Data folder. */
		rc1=metadata_newobj("SASLibrary",luri,"&MetaLibName.","Foundation","&folder_uri","Members");

       
		/* Add PublicType,UsageVersion,Engine,Libref,IsDBMSLibname attribute values. */
		rc2=metadata_setattr(luri,"PublicType","Library");
		rc3=metadata_setattr(luri,"UsageVersion","1000000.0");
		rc4=metadata_setattr(luri,"Engine","ODBC");
		rc5=metadata_setattr(luri,"Desc","&Desc.");
		rc6=metadata_setattr(luri,"Libref","&LibRefName");
		rc7=metadata_setattr(luri,"IsDBMSLibname","1");

		/* Set Directory Object via UsingPackages Association for the SAS Library Object */
		rc8=metadata_newobj("DatabaseSchema",uri,"");
		rc9=metadata_setassn(luri,"UsingPackages","Replace",uri);
		rc10=metadata_setattr(uri,"SchemaName","&DatabaseSchema.");
	        rc46=metadata_setattr(uri,"Name","&LibRefName.");


		/* Set Server Context Object via DeployedComponents Association for the SAS Library Object */
		rc11=metadata_getnobj("omsobj:ServerContext?@Name='SASApp'",1,muri);
		rc12=metadata_setassn(luri,"DeployedComponents","Append",muri);

		/* Set SASClientConnection */
		rc13=metadata_getnobj("omsobj:SASClientConnection?@Name='Connection: &Connection.'",1,lcuri);
		rc14=metadata_setassn(luri,"LibraryConnection","Append",lcuri);
	
		/* Set Prototype */
		rc15=metadata_getnobj("omsobj:Prototype?@Name='Library.ODBC.Prototype.Name.xmlKey.txt'",1,puri);
		rc16=metadata_setassn(luri,"UsingPrototype","Append",puri);

		/* Set AssignMode */
		rc17=metadata_newobj("Extension",euri,"AssignMode","Foundation",luri,"Extensions");
		rc18=metadata_setattr(euri,"Value","&AssignMode");

		/* Property: READ_ISOLATION_LEVEL */
		rc19=metadata_newobj("Property",propuri1,"Library.DBMS.Property.ReadIsoLvl.Name.xmlKey.txt","Foundation",luri,"Properties");
		rc20=metadata_setattr(propuri1,"DefaultValue","RU");
	    rc21=metadata_setattr(propuri1,"Delimiter","=");
		rc22=metadata_setattr(propuri1,"PropertyName","READ_ISOLATION_LEVEL");

		/* Property: CONNECTION */
		rc23=metadata_newobj("Property",propuri2,"Library.DBMS.Property.ConnType.Name.xmlKey.txt","Foundation",luri,"Properties");
		rc24=metadata_setattr(propuri2,"DefaultValue","GLOBAL");
	    rc25=metadata_setattr(propuri2,"Delimiter","=");
		rc26=metadata_setattr(propuri2,"PropertyName","CONNECTION");

		/* Property: Autocommit */
		rc27=metadata_newobj("Property",propuri3,"Library.DBMS.Property.AUTOCOMMIT.Name.xmlKey.txt","Foundation",luri,"Properties");
		rc28=metadata_setattr(propuri3,"DefaultValue","NO");
	    rc29=metadata_setattr(propuri3,"Delimiter","=");
		rc30=metadata_setattr(propuri3,"PropertyName","AUTOCOMMIT");

		/* Property: INSERTBUFF */
		rc30=metadata_newobj("Property",propuri4,"Library.DBMS.Property.InsertBuff.Name.xmlKey.txt","Foundation",luri,"Properties");
		rc31=metadata_setattr(propuri4,"DefaultValue","1000");
	    rc32=metadata_setattr(propuri4,"Delimiter","=");
		rc33=metadata_setattr(propuri4,"PropertyName","INSERTBUFF");

		/* Property: READBUFF */
		rc34=metadata_newobj("Property",propuri5,"Library.DBMS.Property.ReadBuff.Name.xmlKey.txt","Foundation",luri,"Properties");
		rc35=metadata_setattr(propuri5,"DefaultValue","32767");
	    rc36=metadata_setattr(propuri5,"Delimiter","=");
		rc37=metadata_setattr(propuri5,"PropertyName","READBUFF");

		/* Property: DBCOMMIT */
		rc38=metadata_newobj("Property",propuri6,"Library.DBMS.Property.DBCommit.Name.xmlKey.txt","Foundation",luri,"Properties");
		rc39=metadata_setattr(propuri6,"DefaultValue","10000");
	    rc40=metadata_setattr(propuri6,"Delimiter","=");
		rc41=metadata_setattr(propuri6,"PropertyName","DBCOMMIT");

		/* Property: DIRECT_EXE */
		rc42=metadata_newobj("Property",propuri7,"Library.DBMS.Property.DirectExe.Name.xmlKey.txt","Foundation",luri,"Properties");
		rc43=metadata_setattr(propuri7,"DefaultValue","DELETE");
	    rc44=metadata_setattr(propuri7,"Delimiter","=");
		rc45=metadata_setattr(propuri7,"PropertyName","DIRECT_EXE");

run;

I register the table metadaten with the following snippit afterwards: 

 

%do i=1 %to &n;

     proc metalib;
             omr (library="&&name&i");
                 update_rule=(delete);
				 FOLDER = "&&tree_path&i.";
             report;
        run;
%end;

When I click on the table object I get this erros message:

 

klroesner_0-1677180952009.png

 

The field DBMS contains a wrong value "Aster" (the right value would be: ODBC) and the Library is empty:

 

klroesner_1-1677181109415.png

 

What could be the mistake?

 

Best regards,

Klaus

 

1 ACCEPTED SOLUTION

Accepted Solutions
klroesner
Obsidian | Level 7

I got my mistake:

 

		/* Set Server Context Object via DeployedComponents Association for the SAS Library Object */
		rc11=metadata_getnobj("omsobj:ServerContext?@Name='SASApp'",1,muri);
		rc12=metadata_setassn(luri,"DeployedComponents","Append",muri);

		/* Set Directory Object via UsingPackages Association for the SAS Library Object */
		rc8=metadata_newobj("DatabaseSchema",uri,"&MetaLibName","Foundation",muri,"DataPackages");
		rc9=metadata_setassn(luri,"UsingPackages","Replace",uri);
		rc10=metadata_setattr(uri,"SchemaName","&DatabaseSchema.");

I forgot the Link from the DatabaseSchema to the Server Context.

View solution in original post

2 REPLIES 2
gwootton
SAS Super FREQ
Does PROC METALIB create the table without issue if you use SAS Management Console to create the library instead of your macro? That should help identify if the issue is with your macro or with PROC METALIB.
--
Greg Wootton | Principal Systems Technical Support Engineer
klroesner
Obsidian | Level 7

I got my mistake:

 

		/* Set Server Context Object via DeployedComponents Association for the SAS Library Object */
		rc11=metadata_getnobj("omsobj:ServerContext?@Name='SASApp'",1,muri);
		rc12=metadata_setassn(luri,"DeployedComponents","Append",muri);

		/* Set Directory Object via UsingPackages Association for the SAS Library Object */
		rc8=metadata_newobj("DatabaseSchema",uri,"&MetaLibName","Foundation",muri,"DataPackages");
		rc9=metadata_setassn(luri,"UsingPackages","Replace",uri);
		rc10=metadata_setattr(uri,"SchemaName","&DatabaseSchema.");

I forgot the Link from the DatabaseSchema to the Server Context.

suga badge.PNGThe SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment. 

Join SUGA 

Get Started with SAS Information Catalog in SAS Viya

SAS technical trainer Erin Winters shows you how to explore assets, create new data discovery agents, schedule data discovery agents, and much more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 691 views
  • 0 likes
  • 2 in conversation