本文介绍了获取 SAS 表元数据 URI 的通用方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个利用表对象的 SAS 元数据 ID(或 URI)的实用程序.以下代码适用于在库使用 BASE 引擎时获取 ID:

I'm building a utility that leverages the SAS metadata ID (or URI) of a table object. The following code works fine for getting the ID when the library uses the BASE engine:

%let mylib=SOMELIB;
data output (keep=uri dataname);
  length uri $100 dataname $256;
  uri='';
  i=1;
  do until (rc<0);
    rc=metadata_getnasn("omsobj:SASLibrary?@Libref='&mylib'","Tables",i,uri);
    put rc=;
    prc=metadata_getattr(uri,"Name",dataname);
    if rc>=0 then output;
    i+1;
    put i=;
  end;
run;

然而,对于其他库引擎(例如 OLEDB、ODBC、REMOTE),SAS 会将信息存储在不同的属性中(例如,在UsingPackages/[my db]/Tables"下).我可以为遇到的每个库引擎编写条件逻辑,但想知道是否有更简单/更通用的方法来获取表 ID?

However for other library engines (eg OLEDB, ODBC, REMOTE) SAS will store the information in different properties (eg under "UsingPackages/[my db]/Tables"). I can write conditional logic for each of the library engines I come across, but wondered if there was an easier / more generic way to get the Table ID?

同样的问题反过来发生(如果我搜索表,我仍然需要 SASLibrary 以确保它是唯一的).

The same issue occurs in reverse (if I search for the Table I still need the SASLibrary to ensure it is unique).

推荐答案

本文中的代码对我们的 SAS 管理员非常有帮助:

The code in this article was extremely helpful for our SAS admins:

http://support.sas.com/documentation/cdl/en/lrmeta/63180/HTML/default/viewer.htm#p1k9zipe59ha2an1pq34gu143lay.htm

示例:列出库及其服务器上下文

该程序使用SAS元数据DATA步函数返回更多有关库的详细信息.结果返回到工作库中的库数据集.请求的数据包括库元数据 ID、库名称、libref、引擎、路径文件系统(或者 DBMS 数据,DBMS 路径)和服务器上下文库所关联的.

This program uses the SAS metadata DATA step functions to return more detailed information about the libraries. The results are returned to a Libraries data set in the Work library. The requested data includes the library metadata ID, the library name, libref, engine, path on the file system (or if DBMS data, the DBMS path), and the server contexts to which the library is associated.

它会给你你想要的一切,甚至更多.

It'll give you everything you want and more.

这篇关于获取 SAS 表元数据 URI 的通用方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 05:27