Migrating a SAS library is comprised of three phases. First, before executing PROC MIGRATE, a snapshot or record of the contents of existing libraries is derived. Then PROC MIGRATE is executed. Finally, the migrated libraries are compared to the source libraries for validation.
These steps are contained in the migrate_template.sas tool provided by SAS, which you modify for your specific site. Because you are likely to have a large number of members in a source library, as well as having different member types, the validation process has been automated using SAS macros within the validation tools. The validation tools are discussed on the SAS Migration Community web site, in particular, see http://support.sas.com/rnd/migration/resources/procmigrate/validtools.html.
In order to validate the migration, you must document the members in the source library and the attributes of each member before the migration so you can compare the information after migration to the target library. To understand the reports that are produced with the validation, you must understand the attributes that are expected to change during migration. You will see different engines are used for different libraries, such as V9 instead of V6. Also, encoding is a new attribute in SAS 9.
Unfortunately, knowing your data is not as simple as knowing what member types exist in a source library. You must consider the hidden complexities of each SAS data set. Do your data files have indexes, integrity constraints, password protection, permanent formats, variable lengths, data set labels, or data representation and encoding other than the default?
SAS created validation macros to gather the details of the libraries for you. These macros, provided in the migrate_macros.sas tool, are wrapped in a single wrapper macro, %BEFORE, and are executed by the migrate_template.sas tool prior to executing PROC MIGRATE.
After the migrate_template.sas tool runs the %BEFORE macro the PROC MIGRATE step is executed. You modify the migrate_template.sas tool to include the PROC MIGRATE options you want to use.
The wrapper macro %AFTER includes the macros that compare the source library to the target library. Additionally, the wrapper macro %CHECKEM calls the memtype comparison macros to check the members for final validation of the process. The memtypes that are checked are:
catalogs
SQL views
data files.
The new migration process uses ODS for reporting the various steps in the process.
You need a listing of the source library to compare to the target library after the migration. PROC CONTENTS prints a listing of the contents of a SAS library. You could compare the source library listing to the target listing manually but this would be time consuming. Using ODS, you will see only a listing of the attributes that are different in the source and target libraries.
The migrate_template.sas tool requires that all the necessary macros be compiled or included in the program before execution. The migrate_macros.sas tool contains all the required macros and compiles the macros for you when the migrate_macros.sas tool is submitted.
The new SAS macros provided in the migrate_macros.sas tool are:
%MIG_IN_LIB
documents the contents of the source library by creating a new data set in the ODS library that contains the name and memtype of each member in the library. (Later in the program it is called again to document the contents of the target library.)
%MIG_SOURCE
uses the source library data set created by the %MIG_IN_LIB macro to create memtype flag variables for each member, which indicate the presence of files of a particular memtype in the source library. These variables are used by the memtype validation macros.
%MIG_INDEXES
only include this macro for libraries that contain data files with indexes or integrity constraints, because these two types of members are handled differently and could cause unexpected COMPARE differences.
%MIG_CHECK_LIBS
compares the contents of the source library before migration with the contents of the target library after migration.
%MIG_CHECK_SOURCE
compares of the contents of the source library before migration with the contents of the source library after migration.
%CHECKDATA, %CHECKCATALOG, %CHECKVIEW, %CHECKAUDIT, %CHECKINDEX
these memtype validation macros use the %MIG_SOURCE variables to produce output that contains only the data set attributes and engine/host data which are different in the source library and the target library.
There are three wrapper macros that use all the macros mentioned above. The %BEFORE macro runs before PROC MIGRATE and the %AFTER and %CHECKEM macros run after PROC MIGRATE. SAS has provided these wrapper macros to simplify the library migration process by including them in the migrate_template.sas tool:
%BEFORE
wraps all the macros needed before PROC MIGRATE is run. The migrate_template.sas tool calls the %BEFORE wrapper macro instead of calling each macro individually.
The %BEFORE runs the following three macros for you:
%mig_in_lib; %mig_source; %mig_indexes;
%AFTER
wraps all the macros required to validate the PROC MIGRATE results. %AFTER is also referenced by the migrate_template.sas tool instead of calling each macro individually.
The %AFTER runs the following five macros for you:
%mig_in_lib(lib=lib1, after=y); %mig_in_lib(lib=lib2); %mig_indexes(lib=LIB2); ****must be upper case; %mig_check_libs; %mig_check_source;
%CHECKEM
wraps all the memtype macros required to run all of the individual memtype validation macros with a single macro call. The %CHECKEM runs the following five macros for you:
%checkdata; %checkview; %checkaudit; %checkindex; %checkcatalog;
The following table shows the memtype macros that validate each memtype or file. All of the memtype macros are contained within the %CHECKEM wrapper macro:
Memtype or File | Validation Macro |
---|---|
catalog (catalog attributes only) | %CHECKCATALOG |
data set | %CHECKDATA |
data file with an index | %CHECKDATA and %CHECKINDEX |
data file with integrity constraint | %CHECKDATA and %CHECKINDEX |
data file with an audit trail | %CHECKDATA and %CHECKAUDIT |
generations | %CHECKDATA |
SQL view | %CHECKVIEW |
Here is an example of the simplest form of the migrate_template.sas tool:
libname lib1 <engine> 'path to source library'; libname lib2 base 'path to target library'; libname ods 'path used by the tools'; %before;
proc migrate in=lib1 out=lib2;run; %after; %checkem;
If the LIB1, LIB2 and ODS libraries have been defined correctly, and the migrate_macros.sas tool has been compiled in the same SAS session, the %BEFORE does the following:
creates a data set in the ODS library containing information about the members in the source library before PROC MIGRATE.
creates global macro (flag) variables for each memtype.
creates global macro variables containing the name of each member in the source library before PROC MIGRATE.
creates a global macro variable which indicates whether or not there are any integrity constraints in the source library before PROC MIGRATE.
if there are any indexes and/or integrity constraints in the source library, %BEFORE creates a data set in the ODS library describing the indexes, the integrity constraints, audit trails, or generations data sets in the source library before PROC MIGRATE.
The %AFTER macro does the following:
creates a data set in the ODS library containing information about the members in the source library after PROC MIGRATE.
creates a data set in the ODS library containing information about the members in the target library after PROC MIGRATE.
if there are any indexes and/or integrity constraints in the source library, %AFTER creates a data file in the ODS library which describes the indexes and/or the integrity constraints in the target library after PROC MIGRATE.
outputs a side-by-side comparison of the contents of the source library before the PROC MIGRATE with the contents of the target library after the PROC MIGRATE in the SAS output window.
outputs a side-by-side comparison of the contents of the source library before the PROC MIGRATE with the contents of the source library after the PROC MIGRATE in the SAS output window.
The %CHECKEM macro does the following:
checks the data set attributes and engine/host data for differences between the source library catalogs and the target library catalogs.
checks the data set attributes and engine/host data for differences between any SQL views in the source library and the same SQL views in the target library.
checks the source library and target library attributes for data files and data files with indexes, integrity constraints, audit trails and generations data sets.
Outputs a side-by-side comparison of the source library and target library for each of the above checks.