BookmarkSubscribeRSS Feed
FK1
Lapis Lazuli | Level 10 FK1
Lapis Lazuli | Level 10

 Hello,

 

I cannot grasp as of why I get two different results in the sense of number of libraries, when running theses two codes:

 

data work.list_with_116;
	keep name engine ;

	* Temp-Variablen;
	length uri_lib $256.;

	* Ausgabe-Variablen;
	length name $200.;
	length engine $32.;
	
	nobj=-1;
	n=1;

	*Foundation(Repository) > SASLibrary(Objekt);
	nobj = metadata_getnobj("omsobj:SASLibrary?@Id contains '.'", n, uri_lib);

	if nobj>0 then
		do;
			do i=1 to nobj;
				nobj2 = metadata_getnobj("omsobj:SASLibrary?@Id contains '.'", i, uri_lib);
				rc1 = metadata_getattr(uri_lib, "Name", name);
				rc2 = metadata_getattr(uri_lib, "Engine", engine);
					output;
			end;
		end;
run;

and

 

 

data work.list_with_114;

length serveruri liburi upasnuri $256 Bibliotheksname ServerContext $128 type id $17 Libref Engine $8 Physischer_Pfad Datenkbankschema_Label Datenkbankschema_Name $256;

keep ServerContext Bibliotheksname Libref Engine Physischer_Pfad Datenkbankschema_Label Datenkbankschema_Name;

/*Initialisieren, damit keine Notes im Log auftauchen*/
call missing(serveruri, liburi, upasnuri, ServerContext, Bibliotheksname, Engine, Libref);

/*Mit "1" initialisieren, wird dann in der Schleife unten hochgezaehlt */
nlibobj=1;

/*librc = Anzahl der Bibliotheken die gefunden wurden*/
librc=metadata_getnobj("omsobj:SASLibrary?@Id contains '.'",nlibobj,liburi);

	do while (librc>0);
		rc=metadata_getattr(liburi,'Name',Bibliotheksname);
		rc=metadata_getattr(liburi,'Engine',Engine);
		rc=metadata_getattr(liburi,'Libref',Libref);


		n=1;
		uprc=metadata_getnasn(liburi,'UsingPackages',n,upasnuri);
		rc=metadata_getnasn(liburi, "DeployedComponents", n, serveruri);
		rc=metadata_getattr(serveruri, "Name", ServerContext);



		if uprc > 0 then do;
				call missing(type,id,Physischer_Pfad,Datenkbankschema_Label,Datenkbankschema_Name);
				rc=metadata_resolve(upasnuri,type,id);
					if type='Directory' then do;
							rc=metadata_getattr(upasnuri,'DirectoryName',Physischer_Pfad);
							output;
					end;
					else if type='DatabaseSchema' then do;
							rc=metadata_getattr(upasnuri,'Name',Datenkbankschema_Label);
							rc=metadata_getattr(upasnuri,'SchemaName',Datenkbankschema_Name);
							output;
					end;
				n+1;
				uprc=metadata_getnasn(liburi,'UsingPackages',n,upasnuri);
		end;

		nlibobj+1;

		put nlibobj=;

		librc=metadata_getnobj("omsobj:SASLibrary?@Id contains '.'",nlibobj,liburi);

	end;



run;

When comparing the two created datasets "work.list_with_116" (this dataset has 116 observations") and "work.list_with_114" (this dataset has 114 observations") , I can see, that in "work.list_with_114" two rows, i.e. two libraries, are missing, namely:

 

two_libs.PNG

 

 

What kind of engine is "list" ?

Why are they not in "work.list_with_114" compared to "work.list_with_116"?

 

Any help would be highly appreciated.

Cheers,

FK1

 

7 REPLIES 7
ChrisNZ
Tourmaline | Level 20

Did you ask tech support? Did you get the the bottom of this?

FK1
Lapis Lazuli | Level 10 FK1
Lapis Lazuli | Level 10

Hi @ChrisNZ ,

no, so far I did not get to the bottom of this. But I contacted Tech Support to see, whether they can answer my question.

I'll keep you posted, as soon as I will have gotten an answer...

 

FK1
Lapis Lazuli | Level 10 FK1
Lapis Lazuli | Level 10

Hey @ChrisNZ ,

the problem seems to be, that the condition

if uprc > 0 then do;

is not greater than zero for some libraries!

When I put the values to the log, I can see that for two libraries (i.e. for iteration #73 and #74) uprc = -4

ANFANG DO WHILE: nlibobj=73
rc=0
rc=0
rc=0
NOTE: UPRC: uprc=-4
NOTE: LIBURI: liburi=OMSOBJ:SASLibrary\A50H6R4H.B500001B
NOTE: N: n=1
NOTE: upasnuri: upasnuri=OMSOBJ:DatabaseSchema\A50H6R4H.BQ000012
ENDE DO WHILE: nlibobj=74
NOTE: im DO WHILE librc=116 (number of libraries)
ANFANG DO WHILE: nlibobj=74
rc=0
rc=0
rc=0
NOTE: UPRC: uprc=-4
NOTE: LIBURI: liburi=OMSOBJ:SASLibrary\A50H6R4H.B500001A
NOTE: N: n=1
NOTE: upasnuri: upasnuri=OMSOBJ:DatabaseSchema\A50H6R4H.BQ000012

So, the real qustion is, why does the "metadata_getasn"-function throw a "-4" with the given parameters?

uprc=metadata_getnasn(liburi,'UsingPackages',n,upasnuri);

When resolving the parameters for iteration #73,74 the code looks like this:

metadata_getnasn("OMSOBJ:SASLibrary\A50H6R4H.B500001B",'UsingPackages',1,"OMSOBJ:DatabaseSchema\A50H6R4H.BQ000012");
metadata_getnasn("OMSOBJ:SASLibrary\A50H6R4H.B500001A",'UsingPackages',1,"OMSOBJ:DatabaseSchema\A50H6R4H.BQ000012");

Refering to the Documentation of the metadata_getasn function 

I can read that return code = -4 means that "n is out of range"...

 

Do you know, why this return code is being sent back for the two libraries, whereas for all other 114 libraries it works well?

 

ChrisNZ
Tourmaline | Level 20

@FK1  It's so nice to read well-presented well-articulated posts!

 

I do not know why -4 is returned for these two entries, but what it means is that there is no associated object number 1 for this association. In other words the association seems to be empty.

 

Does this help? If not, again Tech Support might know more.

 

Moving the discussion to the admin community where it might be seen by more knowledgeable people.

gwootton
SAS Super FREQ

It looks like your second code only outputs if uprc > 0, so if a SASLibrary object does not have a "UsingPackages" association it would not be listed.
If you ran the libname statement:

libname <libref> list;

It would return information on that library or that the library is not assigned.

 

You could modify your query to this to exclude those libraries:

omsobj:SASLibrary?SASLibrary[@Id contains '.'][UsingPackages/*]
--
Greg Wootton | Principal Systems Technical Support Engineer
FK1
Lapis Lazuli | Level 10 FK1
Lapis Lazuli | Level 10

Thank you, @ChrisNZ  for the compliment 🙂 

 

Also, @gwootton , thank you for your suggestion.

The nucleus of the problem can be circumvented by using your suggested code snippet.

 

In general, I must admit, that I do not have the deep dive insights, yet, of the SAS Open Metadata Architecture.

For example, it would be very helpful to me, to know in general, which oms objects elements are available, like e.g.

 

 

 

 

omsobj:SASLibrary

 

 

 

 

I guess, I have to study the SAS® 9.4 Metadata Model: Reference 

There, I can find the complete list of Meta Data Types, that can be queried:
https://support.sas.com/documentation/cdl/en/omamodref/67417/HTML/default/viewer.htm#alphalist.htm 

 

 

gwootton
SAS Super FREQ
Correct, the Metadata Model reference is where you would see all the objects. You may also be interested in using the metabrowse function in base SAS to explore the repository and its objects/associations.

https://blogs.sas.com/content/sastraining/2012/06/12/using-metabrowse-to-find-metadata/
--
Greg Wootton | Principal Systems Technical Support Engineer

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
  • 7 replies
  • 1601 views
  • 9 likes
  • 3 in conversation