1 The SAS System 09:33 Thursday, May 18, 2017 1 %_eg_hidenotesandsource; 5 %_eg_hidenotesandsource; 29 30 31 /*Connect to the metadata server. */ 32 33 options metaserver="myserver.net" 34 metaport=8561 35 metauser="sasadm@saspw" /* The domain-qualified user ID for the connection to */ 36 /* the metadata server. */ 37 metapass=XXXXXXXXXX 38 metarepository="Foundation"; 39 40 /* Begin the query. The DATA statement names the output data set. */ 41 42 data metadata_libraries; 43 44 /* The LENGTH statement defines variables for function arguments and 45 assigns the maximum length of each variable. */ 46 47 length liburi upasnuri $256 name $128 type id $17 libref engine $8 path 48 mdschemaname schema $256; 49 50 /* The KEEP statement defines the variables to include in the 51 output data set. */ 52 53 keep name libref engine path mdschemaname schema; 54 55 /* The CALL MISSING routine initializes the output variables to missing values. */ 56 57 call missing(liburi,upasnuri,name,engine,libref); 58 59 /* The METADATA_GETNOBJ function specifies to get the SASLibrary objects 60 in the repository. The argument nlibobj=1 specifies to get the first object that 61 matches the requested URI. liburi is an output variable. It will store the URI 62 of the returned SASLibrary object. */ 63 64 nlibobj=1; 65 librc=metadata_getnobj("omsobj:SASLibrary?@Id contains '.'",nlibobj,liburi); 66 67 /* The DO statement specifies a group of statements to be executed as a unit 68 for each object that is returned by METADATA_GETNOBJ. The METADATA_GETATTR function 69 is used to retrieve the values of the Name, Engine, and Libref attributes of 70 the SASLibrary object. */ 71 72 do while (librc>0); 73 74 /* Get Library attributes */ 75 rc=metadata_getattr(liburi,'Name',name); 76 rc=metadata_getattr(liburi,'Engine',engine); 77 rc=metadata_getattr(liburi,'Libref',libref); 78 79 /* The METADATA_GETNASN function specifies to get objects associated to the 80 library via the UsingPackages association. The n argument specifies to return the 81 first associated object for that association type. upasnuri is an output variable. 82 It will store the URI of the associated metadata object, if one is found. */ 83 84 n=1; 2 The SAS System 09:33 Thursday, May 18, 2017 85 uprc=metadata_getnasn(liburi,'UsingPackages',n,upasnuri); 86 87 /* When a UsingPackages association is found, the METADATA_RESOLVE function 88 is called to resolve the URI to an object on the metadata server. The CALL MISSING 89 routine assigns missing values to output variables. */ 90 91 if uprc > 0 then do; 92 call missing(type,id,path,mdschemaname,schema); 93 rc=metadata_resolve(upasnuri,type,id); 94 95 /* If type='Directory', the METADATA_GETATTR function is used to get its 96 path and output the record */ 97 98 if type='Directory' then do; 99 rc=metadata_getattr(upasnuri,'DirectoryName',path); 100 output; 101 end; 102 103 /* If type='DatabaseSchema', the METADATA_GETATTR function is used to get 104 the name and schema, and output the record */ 105 106 else if type='DatabaseSchema' then do; 107 rc=metadata_getattr(upasnuri,'Name',mdschemaname); 108 rc=metadata_getattr(upasnuri,'SchemaName',schema); 109 output; 110 end; 111 112 /* Check to see if there are any more Directory objects */ 113 114 n+1; 115 uprc=metadata_getnasn(liburi,'UsingPackages',n,upasnuri); 116 end; /* if uprc > 0 */ 117 118 /* Look for another library */ 119 120 nlibobj+1; 121 librc=metadata_getnobj("omsobj:SASLibrary?@Id contains '.'",nlibobj,liburi); 122 end; /* do while (librc>0) */ 123 run; NOTE: The data set WORK.METADATA_LIBRARIES has 0 observations and 6 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.03 seconds 124 125 /* Print the metadata_libraries data set */ 126 127 proc print data=metadata_libraries; run; NOTE: No observations in data set WORK.METADATA_LIBRARIES. NOTE: PROCEDURE PRINT used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 128 3 The SAS System 09:33 Thursday, May 18, 2017 129 %_eg_hidenotesandsource; 142 143 144 %_eg_hidenotesandsource; 147