The script does not use data in the traditional sense (SAS tables). It reads and modifies objects (metadata) directly on the SAS metadata server. The 'source' data are the definitions of server contexts and SAS libraries stored in the metadata.
1 Code Block
OPTIONS
Explanation : This block configures the connection parameters for the SAS 9 metadata server (host, port, credentials, repository). These options are necessary for metadata functions to interact with the server. This type of connection is deprecated in SAS Viya 4.
Explanation : This _NULL_ DATA STEP (does not create a table) is the core of the program. It uses SAS 9 metadata functions. First, it uses `metadata_resolve` to find the URI of an application server context ('SASSTP'). If the context is found, it executes a second query to find SAS libraries. For each library found, it uses `metadata_setassn` to associate the server context with it. Error messages are issued and the program stops if the context or libraries are not found.
Copied!
data _null_;
/* Initialize variables. */
length type id app_uri lib_uri $ 50;
call missing(of _character_);
/* Define query for the Application Server Context */
/* to add to the libraries and search for it. */
appobj="omsobj:ServerContext? @Name='SASSTP'";
app_count=metadata_resolve(appobj,type,id);
/* If no context matches this query, stop the program with an error. */
if app_count <= 0 then do;
put "ERROR: No application server context found matching query " appobj;
stop;
end;
else do;
/* Extract the URI of the context if it exists. */
rc=metadata_getnobj(appobj,1,app_uri);
/* Define the query for the libraries to be updated and search for them. */
libobj="omsobj:SASLibrary? @code_sas_json/RFValid.json contains '.'";
lib_count=metadata_resolve(libobj,type,id);
/* If no libraries match the query, stop the program with an error. */
if lib_count <= 0 then do;
put "ERROR: No libraries found matching query " libobj;
stop;
end;
/* If libraries are found, for each one append */
/* the context to its list of associated contexts. */
else do n=1 to lib_count;
rc=metadata_getnobj(libobj,1,lib_uri);
rc=metadata_setassn(lib_uri,"DeployedComponents","Append",app_uri);
end;
end;
run;
1
DATA _null_;
2
3
/* Initialize variables. */
4
5
LENGTH type id app_uri lib_uri $ 50;
6
call missing(of _character_);
7
8
/* Define query for the Application Server Context */
9
/* to add to the libraries and search for it. */
10
11
appobj="omsobj:ServerContext? @Name='SASSTP'";
12
app_count=metadata_resolve(appobj,type,id);
13
14
/* If no context matches this query, stop the program with an error. */
15
16
IF app_count <= 0 THENDO;
17
put "ERROR: No application server context found matching query " appobj;
18
stop;
19
END;
20
ELSEDO;
21
22
/* Extract the URI of the context if it exists. */
23
24
rc=metadata_getnobj(appobj,1,app_uri);
25
26
/* Define the query for the libraries to be updated and search for them. */
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.
« In a SAS 9.4 environment, the relationship between a SAS Library and an Application Server (like SASApp or SASSTP) is defined through a metadata association called DeployedComponents. This script is an excellent administrative tool for bulk-assigning libraries to new server contexts, which is often required during server migrations or when horizontal scaling is implemented. »
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.