我有一个情况,我需要SAS元数据库的用户ID。我不想列出访问元数据的用户。 所以, Fetch user id from SAS metadata server不是我查询的解决方案。
请帮忙
答案 0 :(得分:0)
用于获取ODBC库引擎的凭据(来自元数据)的SAS代码可能如下所示:
%let libref=MYLIB;
/* get liburi */
data _null_;
length lib_uri $256;
call missing (of _all_);
/* get URI for the particular library */
rc=metadata_getnobj("omsobj:SASLibrary?@Libref ='&libref'",1,lib_uri);
call symputx("liburi",lib_uri,'l');
run;
/* query for credentials */
data _null_;
length connx_uri conprop_uri value datasource up_uri schema $256.;
call missing (of _all_);
/* get source connection ID */
rc=metadata_getnasn("&liburi",'LibraryConnection',1,connx_uri);
/* get connection properties */
i=0;
do until (rc2<0);
i+1;
rc2=metadata_getnasn(connx_uri,'Properties',i,conprop_uri);
rc3=metadata_getattr(conprop_uri,'Name',value);
if value='Connection.ODBC.Property.DATASRC.Name.xmlKey.txt' then do;
rc4=metadata_getattr(conprop_uri,'DefaultValue',datasource);
rc2=-1;
end;
end;
/* get SCHEMA */
rc6=metadata_getnasn("&liburi",'UsingPackages',1,up_uri);
rc7=metadata_getattr(up_uri,'SchemaName',schema);
call symputx('SQL_schema',schema,'l');
call symputx('SQL_dsn',datasource,'l');
run;
libname &libref ODBC DATASRC=&sql_dsn SCHEMA=&sql_schema;
可以为其他库类型生成libname语句的宏here。