Previous Page | Next Page

Creating Metadata

Generating Metadata in Batch

The sample metadata-generating program that is supplied with SAS/ASSIST software 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 Creating Metadata of this document.

To create metadata:

  1. Invoke SAS. In the text editor, create a program that defines 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 might want to define additional LIBNAME options that are specific to that system.

  2. Save and run the program.

  3. 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

  4. Define the libraries that are to be included in the metadata. In the program code, you will find this line:

    %let sellib=('INFORMIX', 'SASDATA'); 

    Change the libraries in the parentheses to the libraries that 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');

  5. Further modify the code as desired 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 in Sample Metadata-Generating Program.

  6. Save the file using the following command:

    save metadata.create.metadict.source 

  7. Create the metadata in batch:

    • If this is the first time you are creating metadata in batch, then open the program you created in step one, and modify it to include 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.

    • If you have previously created metadata in batch, simply run 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, are created in the METADATA library. Remember to check the log when this is finished.

Note:   In subsequent batch jobs, the metadata is automatically updated if the metadata tables exist. If they do not exist, the metadata is automatically recreated by SAS/ASSIST software.  [cautionend]

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

Previous Page | Next Page | Top of Page