PROC MIGRATE documentation
![]()
|
When you run PROC MIGRATE with validation tools, you generate Output Delivery System (ODS) reports that validate a successful migration.
The validation tools augment a basic COMPARE procedure by performing a smart compare between source and target libraries.
libname lib1 <engine> 'path to source library'; libname lib2 base 'path to target library'; libname ods 'path used by the tools';
The ODS library should be distinct from the source and target libraries. The optional engine assignment in the first LIBNAME statement is required if you have a mixed library (for example, a library that contains SAS 6 and SAS 8 members). The engine assignment in the first LIBNAME statement specifies which version members you want to migrate. In this case, you must repeat the process for each version your library contains.
proc migrate in=lib1 out=lib2 <options>; run;
For detailed information about the options, see the Options section for PROC MIGRATE.
proc migrate in=lib1 out=lib2 <options>; run;
For detailed information about the options, see the Options section for PROC MIGRATE.
Note that if you have no catalogs in the source library, the SLIBREF= option and the CATLIB libref in the example are not necessary. They will produce a warning that the SLIBREF= is empty.
proc migrate in=lib1 out=lib2 <options>; run;
For detailed information about the options, see the Options section for PROC MIGRATE.
The MOVE option deletes the source library members after they have been migrated to the target library. This might be helpful if you're migrating to a location on the same computer, and you don't have enough space to duplicate the library. Be aware that the MOVE option significantly limits validation, because the validation tools cannot access members that are removed after migration. The %checkem macro cannot be used.
Follow these steps to use the MOVE option with validation tools:
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 move; run; %after;
The migration of a SAS library is comprised of three phases:
Before you execute PROC MIGRATE, a snapshot or record of the contents of existing libraries is derived.
PROC MIGRATE is executed.
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 operating environment.
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 with the use of SAS macros within the validation tools.
The following sections explain how the validation tools work. If you need further information, see details about the validation macros.
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 that 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, such as the following:
indexes
integrity constraints
password protection
permanent formats
variable lengths
SAS data set labels
data representation and encoding other than the default
SAS created validation macros to gather the details of the libraries for you. These macros are provided in the migrate_macros.sas tool and are wrapped in a single wrapper macro named %BEFORE. They are executed by the migrate_template.sas tool prior to the execution of 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 that 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. The CONTENTS procedure prints a listing of the contents of a SAS library. You could compare the source library listing to the target library 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.
Here is an example of the simplest form of the migrate_template.sas tool:
libname lib1 <engine> 'source-library-pathname'; libname lib2 base 'target-library-pathname'; libname ods 'pathname 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 macro completes the following steps:
Creates a SAS data set in the ODS library that contains information about the members in the source library before PROC MIGRATE.
Creates global macro (flag) variables for each memtype.
Creates global macro variables that contains the name of each member in the source library before PROC MIGRATE.
Creates a global macro variable that 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 SAS data set in the ODS library that describes the indexes, the integrity constraints, audit trails, or generation data sets in the source library before PROC MIGRATE.
The %AFTER macro completes the following steps:
Creates a SAS data set in the ODS library that contains 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 that 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.
The %CHECKEM macro does the following:
Checks the SAS data set attributes for differences between the source library catalogs and the target library catalogs.
Checks the SAS data set attributes 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 SAS data sets.
Outputs a side-by-side comparison of the source library and target library for each of the above checks.
The %AFTER macro compares the contents of the source library before PROC MIGRATE with the contents of the target library after PROC MIGRATE by comparing the contents of the SAS data sets created in the ODS library and generating a report.
In the example report below, five members were present in the source library and were migrated successfully to the target library. The C_IND member was not migrated presumably because there was a problem during migration. The SQL_VIEW member is not migrated because it is not in the source library and exists only in the target library.
Obs | name | MemType | result |
---|---|---|---|
1 | FORMATS | CATALOG | OK |
2 | TESTCAT | CATALOG | OK |
3 | C_IND | DATA | not MIGRATED |
4 | DATA_SET | DATA | OK |
5 | ITEMSTORE | ITEMSTOR | OK |
6 | DATA_STEP_VIEW | VIEW | OK |
7 | SQL_VIEW | VIEW | not in source library |
The %CHECKEM macro produces memtype comparison output for only 3 memtypes:
catalogs
SQL views
data files with indexes, integrity constraints, generations, and audit trails
The %CHECKEM macro compares memtypes. It uses the macro variables created by the %BEFORE macro to output the following:
a side-by-side comparison of SAS data set attributes between the source and target libraries
a PROC COMPARE of SAS data set contents
The default behavior of the %CHECKEM macro is to output only those SAS data set attributes and any engine or operating environment data that are different in the source library and the target library.
The first %CHECKEM default output compares the SAS data set attributes and includes the name of the SAS data sets compared in each library.
DATA1 Number 2 of 12 SAS data sets in source library Differences in PROC CONTENTS header information Note: all other header information was the same Number 1 of 2 reports for this SAS data set (from checkdata macro) Obs attribute source target 1 Encoding Default wlatin1 Western (Windows) 2 Engine V8 V9
The second %CHECKEM default output uses PROC COMPARE to compare the SAS data set contents.
DATA1 Number 2 of 12 SAS data sets in source library PROC COMPARE of data Number 2 of 2 reports for this SAS data set (from checkdata macro) The COMPARE Procedure Comparison of LIB1.C_IND with LIB2.C_IND (Method=EXACT) Note: No unequal values were found. All values compared are exactly equal.
The default of %CHECKEM is to output only the SAS data set attributes and engine or operating environment data that are different in the source library and the target library. To output a comparison of all SAS data set attributes and engine or operating environment data, submit the following:
%checkdata(showall=yes);
The first %CHECKEM output with (showall=yes) compares the SAS data set attributes and includes the name of the SAS data sets compared in each library.
DATA1 Number 2 of 12 SAS data sets in source library Comparison of PROC CONTENTS header information Number 1 of 2 reports for this SAS data set (from checkdata macro) Obs attribute source target 1 compressed No No 2 Data Representation WINDOWS WINDOWS 3 Data Set Type 4 Deleted Observations 0 0 5 Encoding Default wlatin1 Western (Windows) 6 Engine V8 V9 7 Indexes 1 1 8 Label 9 Member Type DATA DATA 10 Observation Length 32 32 11 Observations 1 1 12 Protection 13 Sorted No No 14 Variables 4 4
The second %CHECKEM output with (showall=yes) is exactly the same as the %CHECKEM default output:
DATA1 Number 2 of 12 SAS data sets in source library PROC COMPARE of data Number 2 of 2 reports for this SAS data set (from checkdata macro) The COMPARE Procedure Comparison of LIB1.C_IND with LIB2.C_IND (Method=EXACT) Note: No unequal values were found. All values compared are exactly equal.