The script does not operate on data tables (SASHELP or others). It interacts directly with an external source, the SAS 9 metadata server, to read and write information about identities and groups.
1 Code Block
OPTIONS / %LET
Explanation : This block configures the connection parameters to the SAS 9 metadata server (address, port, credentials) and defines the names of the source and destination groups in macro variables. These options are specific to the SAS 9 environment.
/* Specify the source and destination group names. */
15
16
%let source_group_name='source group';
17
%let dest_group_name='destination group';
2 Code Block
DATA STEP
Explanation : This DATA _null_ block uses SAS 9-specific functions to interact with the metadata server. It resolves the URIs of the source and destination groups (`metadata_resolve`), checks for their existence, then loops through each member of the source group (`metadata_getnasn`). For each member, it retrieves their name (`metadata_getattr`) and associates them with the destination group (`metadata_setassn`). The program stops if either group is not found.
Copied!
data _null_;
/* Initialize variables. */
length type1 type2 id1 id2 src_uri dest_uri mem_uri mem_name $ 50;
call missing (of _character_);
/* Define query. */
src_obj="omsobj:IdentityGroup? @Name=&source_group_name";
dest_obj="omsobj:IdentityGroup? @Name=&dest_group_name";
/* Test for the existence of the source group. */
rc1=metadata_resolve(src_obj,type1,id1);
src_uri=cats(type1,'\',id1);
if rc1 < 1 then do; /* If unable to locate, notify and stop. */
put "ERROR: Source group &source_group_name not found in Metadata.";
stop;
end;
/* Test for the existence of the destination group. */
rc2=metadata_resolve(dest_obj,type2,id2);
dest_uri=cats(type2,'\',id2);
if rc2 < 1 then do; /* If unable to locate, notify and stop. */
put "ERROR: Destination group &dest_group_name not found in Metadata.";
stop;
end;
/* Count the number of members in the source group. */
mem_count=metadata_getnasn(src_uri,"MemberIdentities",1,mem_uri);
put "NOTE: Source group &source_group_name has " mem_count "members.";
/* For each member in the source group, add the member to the destination group. */
do n=1 to mem_count;
rc=metadata_getnasn(src_uri,"MemberIdentities",n,mem_uri);
rc=metadata_getattr(mem_uri,"Name",mem_name);
put "NOTE: Adding " mem_name "to destination group &dest_group_name";
rc=metadata_setassn(dest_uri,"MemberIdentities","APPEND",mem_uri);
put mem_uri;
end;
run;
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.
« This script is a powerful utility for SAS 9.4 administrators needing to clone permissions or organizational structures by duplicating group memberships. By utilizing the SAS Metadata Interface, it automates what would otherwise be a tedious manual task in SAS Management Console. »
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.