Los datos se extraen dinámicamente del servidor de metadatos de SAS. El script no lee ninguna fuente de datos externa (archivo, base de datos) ni utiliza tablas SASHELP. Opera directamente sobre los objetos de metadatos devueltos por las funciones SAS.
1 Bloque de código
OPTIONS
Explicación : Este bloque configura las opciones de conexión al servidor de metadatos de SAS. Especifica el host, el puerto, las credenciales del administrador, el repositorio y el protocolo necesarios para interactuar con los metadatos de SAS.
Explicación : Este paso DATA _NULL_ (que no crea una tabla SAS) ejecuta la lógica principal. Define los dominios antiguos y nuevos a través de macrovariables. Utiliza `metadata_resolve` para contar los objetos 'Login' que corresponden a una consulta de metadatos. Si se encuentran objetos, un bucle itera sobre cada 'Login' para recuperar su URI con `metadata_getnobj` y su 'UserID' con `metadata_getattr`. Luego manipula la cadena de caracteres para reemplazar el dominio y actualiza el objeto de metadatos con el nuevo valor mediante `metadata_setattr`, lo que constituye una operación de administración.
¡Copiado!
data _null_;
/* Define the old and replacement domains. */
%let old_domain = domain;
%let new_domain = newdomain;
/* End edit. */
/* Define and initialize variables. */
length type id login_uri user stripped_user new_user $ 60;
call missing(type,id,login_uri,user);
/* This is the query to local the Logins with the old domain. */
obj="omsobj:Login? @code_sas_json/list_defaultauth_userids.json contains '&old_domain\'";
/* Count the number of logins found by the query above. */
count=metadata_resolve(obj,type,id);
/* If logins were found, proceed. */
if count > 0 then do n = 1 to count;
/* Get the Metadata URI for the nth login. */
login_rc=metadata_getnobj(obj,n,login_uri);
/* Pull the full user ID for the login. */
rc=metadata_getattr(login_uri,"UserID",user);
/* Strip the domain from the user ID. */
stripped_user=trim(scan(user,2,'\'));
/* Define a new variable with the new domain and the user ID. */
new_user=cats("&new_domain\",stripped_user);
/* Set this new variable as the UserID attribute. */
rc=metadata_setattr(login_uri,"UserID",new_user);
end;
/* If no logins are found with that domain, write that to the SAS log. */
else put "No users match query";
run;
1
DATA _null_;
2
/* Define the old and replacement domains. */
3
%let old_domain = domain;
4
%let new_domain = newdomain;
5
/* End edit. */
6
7
/* Define and initialize variables. */
8
LENGTH type id login_uri user stripped_user new_user $ 60;
9
call missing(type,id,login_uri,user);
10
11
/* This is the query to local the Logins with the old domain. */
/* Count the number of logins found by the query above. */
15
count=metadata_resolve(obj,type,id);
16
17
/* If logins were found, proceed. */
18
IF count > 0 THENDO n = 1 to count;
19
/* Get the Metadata URI for the nth login. */
20
login_rc=metadata_getnobj(obj,n,login_uri);
21
/* Pull the full user ID for the login. */
22
rc=metadata_getattr(login_uri,"UserID",user);
23
/* Strip the domain from the user ID. */
24
stripped_user=trim(scan(user,2,'\'));
25
/* Define a new variable with the new domain and the user ID. */
26
new_user=cats("&new_domain\",stripped_user);
27
/* Set this new variable as the UserID attribute. */
28
rc=metadata_setattr(login_uri,"UserID",new_user);
29
end;
30
/* If no logins are found with that domain, write that to the SAS log. */
31
else put "No users match query";
32
RUN;
Este material se proporciona "tal cual" por We Are Cas. No hay garantías, expresas o implícitas, en cuanto a la comerciabilidad o idoneidad para un propósito particular con respecto a los materiales o el código contenidos en este documento. We Are Cas no es responsable de los errores en este material tal como existe ahora o existirá, ni We Are Cas proporciona soporte técnico para el mismo.
Información de copyright : Author: Greg Wootton Date: 24MAY2019
SAS y todos los demás nombres de productos o servicios de SAS Institute Inc. son marcas registradas o marcas comerciales de SAS Institute Inc. en los EE. UU. y otros países. ® indica registro en los EE. UU. WeAreCAS es un sitio comunitario independiente y no está afiliado a SAS Institute Inc.
Este sitio utiliza cookies técnicas y analíticas para mejorar su experiencia.
Saber más.