Published on :
Data Management CREATION_INTERNE

SAS Libraries Management

This code is also available in: Deutsch Español
The document 'Examples: Manage SAS© Libraries' offers practical examples and essential information on managing SAS© libraries within the programming environment of the SAS© Viya platform. It demonstrates how to perform fundamental library management tasks, such as migrating libraries to newer SAS© versions, copying entire SAS© libraries, and transferring libraries between different operating environments via transport files. Each example highlights the functionality of specific SAS© procedures like PROC MIGRATE, PROC COPY, PROC CPORT, and PROC CIMPORT, detailing their usage, options, and potential considerations such as cross-environment data access (CEDA) and character encoding. The document also addresses best practices and limitations associated with each method, aiming to provide users with the knowledge necessary to effectively manage their SAS© data assets.
Data Analysis

Type : CREATION_INTERNE


Examples use generated data (datalines) or SASHELP.

1 Code Block
PROC MIGRATE
Explanation :
This example uses the MIGRATE procedure to move members of a SAS library to a newer SAS version. The procedure is the preferred method because it preserves data attributes. The code assumes direct access to source files. Special considerations, such as using a SAS/CONNECT server, are necessary if direct access is not possible or if catalogs are incompatible. Cross-Environment Data Access (CEDA) can be used for read-only access, but with restrictions. The use of the CVP engine may be required to avoid truncation when changing character encoding.
Copied!
1LIBNAME myfiles '<chemin-bibliothèque-1>';
2LIBNAME target '<chemin-bibliothèque-2>';
3PROC MIGRATE in=myfiles out=target;
4RUN;
2 Code Block
PROC COPY
Explanation :
This example illustrates copying a SAS library between different environments using the CPORT and CIMPORT procedures, a multi-step process. The first step (PROC CPORT) creates a transport file ('mytransfer') from the source library. The second step (not shown in the SAS code) involves transferring this binary file to the target environment (e.g., via FTP). The third step (PROC CIMPORT) then imports the contents of the transport file into the target library. It is important to note that PROC CPORT and CIMPORT have limitations compared to PROC MIGRATE, supporting only SAS datasets and catalogs, but not other member types. In case of transcoding to a new encoding, truncation may occur, requiring variable length expansion via the CVP engine or the EXTENDVAR= option of PROC CIMPORT. Transport files created by PROC CPORT are not interchangeable with those created by the XPORT engine.
Copied!
1LIBNAME myfiles '<chemin-bibliothèque-1>';
2LIBNAME target '<chemin-bibliothèque-2>';
3PROC COPY in=myfiles out=target;
4RUN;
3 Code Block
PROC CPORT / PROC CIMPORT
Explanation :
This example illustrates copying a SAS library between different environments using the CPORT and CIMPORT procedures, a multi-step process. The first step (PROC CPORT) creates a transport file ('mytransfer') from the source library. The second step (not shown in the SAS code) involves transferring this binary file to the target environment (e.g., via FTP). The third step (PROC CIMPORT) then imports the contents of the transport file into the target library. It is important to note that PROC CPORT and CIMPORT have limitations compared to PROC MIGRATE, supporting only SAS datasets and catalogs, but not other member types. In case of transcoding to a new encoding, truncation may occur, requiring variable length expansion via the CVP engine or the EXTENDVAR= option of PROC CIMPORT. Transport files created by PROC CPORT are not interchangeable with those created by the XPORT engine.
Copied!
1LIBNAME SOURCE 'c:\example';
2filename tranfile 'c:\myfiles\mytransfer';
3PROC CPORT library=SOURCE file=tranfile;
4RUN;
5 
6/* Transfert du fichier mytransfer vers l'environnement cible (par exemple, via FTP en mode binaire) */
7 
8LIBNAME target '/mydata/example';
9filename tranfile '/mydata/mytransfer';
10PROC CIMPORT library=target INFILE=tranfile;
11RUN;
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.
Copyright Info : Copyright © SAS Institute Inc. All Rights Reserved