如何在SAS中获取元数据对象的详细信息

时间:2019-05-10 19:25:20

标签: sas

我有一个来自存储库的元数据对象列表。我已经获取了所有SASLibrary,PhysicalTable,Jobs对象。现在,我需要获取他们的所有详细信息。有人可以建议我该怎么做吗?我是SAS DI的新手,需要使用SAS代码获取详细信息。 谢谢

2 个答案:

答案 0 :(得分:0)

好吧,假设您有一个包含这些对象的数据集(have),并且uri存储在名为uri的变量中,则以下内容就足够了:

data associations;
  keep assoc assocuri name;
  length assoc assocuri name $256;
  set have;
  rc1=1;n1=1;
  do while(rc1>0);
    /* Walk through all possible associations of this object. */
    rc1=metadata_getnasl(uri,n1,assoc);
    rc2=1;n2=1;
    do while(rc2>0);
      /* Walk through all the associations on this machine object. */
      rc2=metadata_getnasn(uri,trim(assoc),n2,assocuri);
      if (rc2>0) then do;
        rc3=metadata_getattr(assocuri,"Name",name);
        output;
      end;
      call missing(name,assocuri);
      put arc= rc2=;
      n2+1;
    end;
    n1+1;
  end;
run;
proc sort data=associations;
  by assoc name;
run;

proc sql;
create table groupassoc as
  select assoc, count(*) as cnt
  from associations
  group by 1;

data attrprop;
  keep type name value;
  length type $4 name $256 value $32767;
  set have;
  rc1=1;n1=1;type='Prop';
  do while(rc1>0);
    rc1=metadata_getnprp(uri,n1,name,value);
    if rc1>0 then output;
    n1+1;
  end;
  rc1=1;n1=1;type='Attr';
  do while(rc1>0);
    rc1=metadata_getnatr(uri,n1,name,value);
    if rc1>0 then output;
    n1+1;
  end;
run;
proc sort data=attrprop;
  by type name;
run;

也可以使用Base SAS中的metabrowseMetadata Explorer(Boemska的免费网络应用程序,由我帮助构建)来获取此信息。

答案 1 :(得分:0)

例如,

调用此宏以获取您感兴趣的元对象。 fullList表将包含您所有具有metaId和对象类型的有趣对象:

    options Metaport=portnumber;                                                                                                                                                                                                                            
    options MetaUser="userid";                                                                                                                                                                                                                                          
    options Metapass="password";                                                                                                                                                                                                                                           
    options MetaServer="serverName"; 
    options metaprotocol=bridge;

    data fullList;
    length objName $60 objId $17 objType $50;;
    delete;
    run;

    %macro getMeta(objType);
            data temp(keep=objType objName objId);
                length uri $256 objName $60 objId $17 objType $50;
                uri="";n=1;TableName="";
                objType="&objType";
                    do while(metadata_getnobj("omsobj:&objType?@Id ? '.'",n,uri) >= 0);
                            rc=metadata_getattr(uri,"Name",objName);
                            rc=metadata_getattr(uri,"Id",objId);
                            n=n+1; 
                            output;
                    end;
            run;
            proc append base=fullList data=temp;
            run;
    %mend;
    %getMeta(Person);
    %getMeta(PhysicalTable);
    %getMeta(Job);
    %getMeta(JFob);
    .
    .
    . if you want .....