Previous Page | Next Page

Creating Metadata

Sample Metadata-Generating Program

The following program is included with SAS/ASSIST software and can be modified as explained in Generating Metadata in Batch.

/*+-----------------------------------------------------------+
   | Name   : SASHELP.QASSIST.METADICT.SOURCE                  |
   | Purpose: Create ASSIST dictionary tables                  |
   | Product: SAS/ASSIST:                                      |
   |                                                           |
   | Note   : This program creates dictionary tables with      |
   |          long names and their alias.                      |
   |          To define the library for Dictinary tables       |
   |          set the macro variable: dictlib                  |
   |          To select libraries in the query manager tables  |
   |          set the macro variable: sellib                   |
   |                                                           |
   |                                                           |
   +-----------------------------------------------------------+*/

  %let dictlib=Metadata;
 /* Output library for query manager tables              */

 %let sellib=('INFORMIX','SASDATA');     /* <--- THIS MUST BE 
CHANGED TO THE ACTUAL LIBNAMES */
 /* Libraries to be excluded in Dictionary tables        */
 /* To select all:                                       */
 /*  %let sellib=('*');                                  */

%macro upc(macvar,value);
    %global &macvar
    %let &macvar=%upcase(&value);
%mend;

 /* upcase the value of selllib */
%upc(sellib,&sellib);
proc sql;
   create table work.__log
        (db2rc   char(5)  label='Return Code',
        db2msg1 char(70) label='Message-1',
        db2msg2 char(70) label='Message-2',
        db2msg3 char(70) label='Message-3',
        db2msg4 char(70) label='Message-4');
   quit;

proc sql;
   drop table _astdcol;
   drop table _astdtab;

   create table _astdcol as
      select *
          from dictionary.columns
          where libname in &sellib
          order by libname, memname, name;

   create table _astdtab as
      select *
          from dictionary.tables
          where libname in &sellib
          order by libname, memname;

  alter table _astdtab
      modify crdate format=DATETIME19.,
          modate format=DATETIME19.
  ;

/* data &dictlib.._astdtab(index=(libname memname) */
  data &dictlib.._astdtab(label="ASSIST Dictionary tables: Table info");

      set _astdtab;
  run;

/*data &dictlib.._astdcol(index=(libname memname name f_lib f_mem) compress=NO */
  data &dictlib.._astdcol(compress=NO label="ASSIST Dictionary tables: Column info");

      set _astdcol;
      attrib
      index length= $1 format=$1. label="Index"
      f_lib length= $1 format=$1. label="First library"
      f_mem length= $1 format=$1. label="First member"
      ;
      by libname memname;
      f_lib=put(first.libname,1.);
      f_mem=put(first.memname,1.);
      if idxusage eq ' ' then index=' ';
         else index='*';
      if label=' ' then label=name;
  run;

Previous Page | Next Page | Top of Page