Chapter Contents

Previous

Next
Administrator Tasks — Creating Metadata

Generating Metadata in Batch

The sample SQL metadata-generating program supplied with this release can be modified to suit the needs of individual organizations. This section explains how to modify the original program to suit your needs. The original program is included in Sample Metadata-Generating Program of this document.

To create metadata:

  1. Invoke SAS. Create a program defining the library in which metadata will be stored and the libraries that point to the underlying data sources. The METADATA library must be assigned the name METADATA.

    libname metadata <shared location>;
    libname library1 <data source 1>;
    libname library2 <data source 2>;
    ...

    Depending on which DBMS you are assigning libraries to, you may want to define additional LIBNAME options that are specific to that system.

  2. Copy the sample metadata-generating program to your text editor in SAS. Issue the following command in the command line:
    copy sashelp.qassist.metadict.source

  3. Define the libraries to be included in the metadata. In the program code, you will find this line:
    %let sellib=('INFORMIX', SASDATA); 

    Change the libraries in the brackets to the libraries you defined in the LIBNAME statements in step 1. For example, in the following code, the program is modified to include four libnames: DEPOTS, RETURNED, STOCKS, and SUPPLIER.

    %let sellib=('DEPOTS,RETURNED,STOCKS,SUPPLIER);

  4. Further modify the code to customize the task of metadata creation, as shown in the following code:

    create table _astdcol as                                                                                                  
      select *                                                                                                                  
      from dictionary.columns                                                                                                   
      where (libname=DEPOTS and memname in (ROSSLAIGHRE,SHANNON,COVENTRY,LUTON))
      or (libname=SUPPLIER and memname in(MATERIALS,UTILITIES,PACKAGING)) or
      libname in (RETURNED,STOCKS)
      order by libname, memname, name;                                                                                          
                                                                                                                                
      create table _astdtab as                                                                                                  
      select *                                                                                                                  
      from dictionary.tables                                                                                                    
      where (libname=DEPOTS and memname in (ROSSLAIGHRE,SHANNON,COVENTRY,LUTON&))
      or (libname=SUPPLIER and memname in(MATERIALS,UTILITIES,PACKAGING)) or
      libname in (RETURNED,STOCKS)
      order by libname, memname; 

    In the above code, the program is modified so that only a subset of tables in the DEPOTS and SUPPLIER libraries are included in metadata creation. The rest of the program, which does not require any further modifications, is shown below.

  5. Save the file using the following command:
    save metadata.create.metadict.source 

  6. Create the metadata using the following command in SAS:
    af cat=sashelp.qassist.metadict.scl

    When the SAS code you edited above is executed, two SAS tables, _ASTDCOL and _ASTDTAB, will be created in the METADATA library. Remember to check the log when this is finished.

  7. Run this in a batch job. If this is the first time you are running it in batch, create a SAS program that includes the following code:
    libname metadata <shared location>;
    libname library1 <data source 1>;
    libname library2 <data source 2>;
    dm af c=sashelp.qassist.metadict.scl;

    Save the program and execute it in a batch job.

    In subsequent batch jobs, add the following macro to ensure that table and column name aliases in the created metadata do not conflict with aliases that have been saved in previous tasks by SAS/ASSIST software. The macro code should be inserted after the libname statements in the code and reads as follows:

    %let update=Y;

Run the batch job each time that the data structure changes. You may want to run it as a scheduled job.


Chapter Contents

Previous

Next

Top of Page

Terms of Use & Legal Information | Privacy Statement
Copyright © 2001 SAS Institute Inc. All Rights Reserved.