When moving or upgrading data, choosing the right procedure is critical for data integrity. Use PROC MIGRATE as your primary tool for upgrading libraries to newer SAS versions, as it preserves specialized attributes that a simple copy might lose. If you are moving data across different operating environments or encodings, prioritize the CPORT and CIMPORT sequence to ensure compatibility, and always use the CVP (Character Variable Padding) engine to prevent data truncation during encoding shifts. Avoid using operating system file utilities (like Windows Explorer or Linux cp), as these can corrupt SAS-specific file structures and catalogs.
The examples use generic library paths ('library-path-1', 'library-path-2', 'c:\example', '/mydata/example') and transport files ('c:\myfiles\mytransfer', '/mydata/mytransfer'), implying that source data already exists. For standalone execution, these paths would need to be replaced with existing SAS libraries.
1 Code Block
PROC MIGRATE
Explanation : This example uses the PROC MIGRATE procedure to migrate members of a SAS library. Migration allows taking advantage of features in a newer SAS version. This example does not require a SAS/CONNECT server, except in some specific cases. Files created in SAS for Windows are directly accessible in this session.
Explanation : This example uses the PROC COPY procedure to copy the entire 'myfiles' library to the 'target' library. No specific options are specified, meaning the default behavior (like CLONE) is used. Library members are assumed to have the same data representation and encoding as the current session.
Explanation : This step creates a transport file from the source library. The transport file 'mytransfer' is referenced by the fileref 'tranfile'. The PROC CPORT procedure supports datasets and catalogs, but not other member types (like SAS views).
Explanation : This step imports the library from the previously created transport file. The PROC CIMPORT procedure creates the 'target' library by importing the contents of the 'mytransfer' file. The transport file must be transferred in binary mode if a communication software like FTP is used.
When using PROC MIGRATE to move data between different operating systems (like Windows to Linux) or to a different encoding (like WLATIN1 to UTF-8), you should assign the SLIBREF= option in the PROC statement to the source library; this allows the procedure to use the CVP (Compatibility Version Paring) engine implicitly to expand character variable lengths and prevent data truncation without needing a complex LIBNAME statement.
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.