2017-05-17 2 views
0

현재 사용자의 메타 데이터 그룹 구성원을 기반으로 매크로 변수의 값을 (작업 영역 서버의 autoexec 파일에) 설정하려고합니다.현재 사용자의 SAS Metadata 그룹을 얻으려면 어떻게합니까?

사용자가 둘 이상의 그룹에 속할 수 있으며 사용자가 구성원 중 가장 높은 그룹에 따라 변수의 값을 결정하는 논리를 작성할 수 있어야합니다.

SAS 코드에서 메타 데이터를 쿼리하기위한 일반적인 방법을 살펴 보았습니다.하지만 실행중인 사용자에게 관리 역할이 있어야하며 사용자에게는 그렇지 않은 것으로 보입니다.

답변

1

사용자는 메타 데이터를 쿼리하기 위해 관리자 일 필요는 없습니다. 메타 데이터 객체에 대한 읽기 권한이 있어야합니다. 나는 우리의 서버에서 바로 사용자입니다, 나는 http://support.sas.com/kb/30/682.html의 적응 사용하여 사용자 및 관련 그룹 모두의 목록을 얻을 수 있습니다 :

data users_grps (keep=name group email); 
    length uri name groupuri group emailuri email $256 ; 

    call missing(uri, name, groupuri, group, emailuri, email) ;  

    /* Get URI of first person */ 
    n=1; 
    nobj=metadata_getnobj("omsobj:[email protected] contains '.'",n,uri); 
    if nobj=0 then put 'No Persons available.'; 
    do while (nobj > 0); 
     call missing(name, groupuri, group, emailuri, email) ;  

     /* Retrieve the current persons name. */ 
     rc=metadata_getattr(uri, "Name", Name); 

     /* get the persons email address (only first one)*/ 
     rc2=metadata_getnasn(uri,"EmailAddresses",1,emailURI) ; 
     rc3=metadata_getattr(emailuri, "Address", email); 

     /* Get the group association information for the current person. */ 
     a=1; 
     rcgrp=metadata_getnasn(uri,"IdentityGroups",a,groupuri); 

     /* If this person does not belong to any groups, set their group */ 
     /* variable to 'No groups' and output the name. */ 
     if rcgrp in (-3,-4) then do; 
     group="No groups"; 
     output; 
     end; 

     /* If the person belongs to any groups, loop through the list */ 
     /* and retrieve the name of each group, outputting each on a */ 
     /* separate record. */ 
     else do while (rcgrp > 0); 
     rc4=metadata_getattr(groupuri, "Name", group); 
     a+1; 
     output; 
     rcgrp=metadata_getnasn(uri,"IdentityGroups",a,groupuri); 
     end; 

     /* Get URI of next person. */ 
     n+1; 
     nobj=metadata_getnobj("omsobj:[email protected] contains '.'",n,uri); 
    end; 

run; 

가의 그룹을 찾기 위해 적용 할 수있는 생각겠습니까을 현재 사용자.

관련 문제