Type : EXTERNE
Les données sont manipulées directement sur le serveur de métadonnées SAS (OMR) via des fonctions spécifiques (metadata_getnobj, metadata_setassn).
| 1 | options |
| 2 | metaserver="meta.demo.sas.com" |
| 3 | metaport=8561 |
| 4 | metauser="sasadm @saspw" |
| 5 | metapass="password" |
| 6 | metarepository=Foundation |
| 7 | metaprotocol=bridge; |
| 8 | |
| 9 | %let addgroup='Red Test'; |
| 1 | DATA _null_; |
| 2 | /* Initialize variables. */ |
| 3 | LENGTH type id addgroup_uri group_uri group_name $ 50; |
| 4 | call missing (of _character_); |
| 5 | |
| 6 | /* Set queries for all groups and for specific group. */ |
| 7 | group_obj="omsobj:IdentityGroup? @Name=&addgroup"; |
| 8 | allgrp_obj="omsobj:IdentityGroup? @PublicType='UserGroup'"; |
| 9 | |
| 10 | /* Get URI for the group name defined in the 'addgroup' macro variable above. */ |
| 11 | rc=metadata_getnobj(group_obj,1,addgroup_uri); |
| 12 | |
| 13 | /* Count all groups. */ |
| 14 | group_count=metadata_resolve(allgrp_obj,type,id); |
| 15 | |
| 16 | /* If there are groups, do this for each group... */ |
| 17 | IF group_count > 0 THEN DO n=1 to group_count; |
| 18 | /* Get the URI of the group. */ |
| 19 | rc=metadata_getnobj(allgrp_obj,n,group_uri); |
| 20 | /* Get the name of the group. */ |
| 21 | rc=metadata_getattr(group_uri,"Name",group_name); |
| 22 | |
| 23 | /* If the group name is that of the addgroup, do nothing. */ |
| 24 | IF group_name = &addgroup THEN; |
| 25 | ELSE DO; /* If not... */ |
| 26 | put "Adding " group_name; |
| 27 | /* Add it to the membership. */ |
| 28 | rc = metadata_setassn(addgroup_uri,"MemberIdentities","APPEND",group_uri); |
| 29 | END; |
| 30 | END; |
| 31 | RUN; |