how to update the name column in GROUPMEMPERSONS_INFO SAS dataset by removing the existing data in SAS SMC application only SAS users and not for groups
i would need to do this with data step functions and not with import SAS macros please.
please guide.
Thanks @JJP1,
A return code of -3 to the METADATA_SETATTR function means the object you are querying does not exist in Metadata.
I ran your code and it was successful and the description "new description" was removed in SMC.
35 data _null_; 36 set work.Person(where=(keyid='A5KPQZKO.AP000007')); 37 put _all_; 38 if name = "sasadm" or name = "sasevs" or name = "sastrust" then put "Account is sasadm, 38 ! sasevs or sastrust, skipping."; 39 else do; 40 if description ne "" then do; 41 obj="omsobj:Person?@Name='"||name||"'"; 42 rc=metadata_setattr(obj,"Desc",""); 43 put rc=; 44 end; 45 end; 46 run; keyid=A5KPQZKO.AP000007 name=grwoot description=new description title= displayname=Greg Wootton objid=A5KPQZKO.AP000007 externalkey=0 obj= rc=. _ERROR_=0 _N_=1 rc=0 NOTE: There were 1 observations read from the data set WORK.PERSON. WHERE keyid='A5KPQZKO.AP000007'; NOTE: DATA statement used (Total process time): real time 0.12 seconds cpu time 0.03 seconds
Hi @JJP1,
The GROUPMEMPERSONS_INFO dataset is a normal dataset created by the %MDUEXTR User Import Macro that contains a list of group objects members that are users. Are you saying you just want the users from that table (i.e. remove Id and Name columns) or a list of all users in Metadata (contents of the PERSON dataset).
If you want to remove the id and name columns from GROUPMEMPERSONS_INFO with a SAS DATA step you could do this, creating a new dataset "groupper" removing those variables.
data groupper;
set groupmempersons_info;
drop id name;
run;
NO...please.sorry for miscommunication
I need to update the SAS metadata i mean SAS user when it is registered in SMC, the description filed will be there right ? that info i need to remove existing description and add decription for every user based on some conditions using groups & roles that are defined for each user.
for example if user is having SAS Administrator ruler then description should be updated as SAS Admin..like this please.
i can see groups & roles are under showing name column in GROUPMEMPERSONS_INFO dataset file.
So i can see description column in person.person_info datasets .
please note that it is not normat data step. i need help on data step metadata functions to do this job please and not using importad.sas program pleaase
The Metadata DATA Step Function metadata_setattr would be used to specify the description attribute for a person object.
In this case you'd probably want to pull the current description first with metadata_getattr and then append the next group name found.
I recommend taking an ad-hoc metadata backup prior to testing any code that writes to metadata.
For example, something like this would remove the description for any user who had one in the person table from Metadata in the first data step, then create a description that is a comma separated list of groups they are a member of from groupmempersons_info in the second data step:
/* Remove the existing description from any user with one in Person table except sasadm/sasevs/sastrust. */ data _null_; set work.person; if name = "sasadm" or name = "sasevs" or name = "sastrust" then put "Account is sasadm, sasevs or sastrust, skipping."; else do; if description ne "" then do; obj="omsobj:Person?@Name='"||name||"'"; rc=metadata_setattr(obj,"Desc",""); end; end; run; /* Add groups from groupmempersons_info to user's description for any user except sasadm/sasevs/sastrust */ data _null_; set work.groupmempersons_info; length desc $255; call missing (desc); if memName = "sasadm" or memname = "sasevs" or memname = "sastrust" then put "Account is sasadm, sasevs or sastrust, skipping."; else do; obj="omsobj:Person?@Name='"||memName||"'"; rc=metadata_getattr(obj,"Desc",desc); if desc ne "" then desc=cats(desc,", ",Name); else desc=Name; rc=metadata_setattr(obj,"Desc",desc); end; run;
Thanks @gwootton it is working..
i took the backup and tested for single record and i can see that for roles 'SAS admintsrator's' and DI Deveopers for my name came to description filed as 'SASAdministrators,DI Developers'.
But i need to display under description filed in customised format please..
for example if role in (SAS admintsrator's' and DI Deveopers) then description should be 'SAS Administrator'
if role in (DI Deveopers) then Description should be S'AS Developer '
Actually i am having set of roles for which i need to create customised the description values based on roles for users.
Would you please guide on this please and i thank you so much for your help on this please
Hi @gwootton ,
iam trying below code for one record to test if group is SASAdministartor then Desc should be SAS Adminstartors.
But in SAS EG code it runs fine with out errors but i can not see the changes as expected in SMC
data _null_;
set work.groupmempersons_info(where=(memid='XXXXXX'));
length desc $255;
call missing (desc);
if memName = "sasadm" or memname = "sasevs" or memname = "sastrust" then put "Account is sasadm, sasevs or sastrust, skipping.";
else if Name='SAS Administrators' then desc='SAS Administrators';
rc=metadata_setattr(obj,"Desc",desc);
run;
Hi @JJP1 ,
The name of the SAS Adminstrators group is "SASAdministrators" (no space). Does removing the space apply the description as expected?
No.it's not getting update please . i tried by removing the space also
Hi All,
sorry to bother. any help on this please.
Hi @gwootton ,
iam trying below code to remove existing description but it is not working and reflecting in SMC actually retirn code =-3 getting . please help.
data _null_;
set work.Person(where=(keyid='XXXX'));
if name = "sasadm" or name = "sasevs" or name = "sastrust" then put "Account is sasadm, sasevs or sastrust, skipping.";
else do;
if description ne "" then do;
obj="omsobj:Person?@Name='"||name||"'";
rc=metadata_setattr(obj,"Desc","");
end;
end;
run;
Note : iam using correct keyid value. please help
Thanks @JJP1,
A return code of -3 to the METADATA_SETATTR function means the object you are querying does not exist in Metadata.
I ran your code and it was successful and the description "new description" was removed in SMC.
35 data _null_; 36 set work.Person(where=(keyid='A5KPQZKO.AP000007')); 37 put _all_; 38 if name = "sasadm" or name = "sasevs" or name = "sastrust" then put "Account is sasadm, 38 ! sasevs or sastrust, skipping."; 39 else do; 40 if description ne "" then do; 41 obj="omsobj:Person?@Name='"||name||"'"; 42 rc=metadata_setattr(obj,"Desc",""); 43 put rc=; 44 end; 45 end; 46 run; keyid=A5KPQZKO.AP000007 name=grwoot description=new description title= displayname=Greg Wootton objid=A5KPQZKO.AP000007 externalkey=0 obj= rc=. _ERROR_=0 _N_=1 rc=0 NOTE: There were 1 observations read from the data set WORK.PERSON. WHERE keyid='A5KPQZKO.AP000007'; NOTE: DATA statement used (Total process time): real time 0.12 seconds cpu time 0.03 seconds
The SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment.
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.