Published on :
SAS Engines CREATION_INTERNE

Using a SAS Engine to Process SAS Data

This code is also available in: Deutsch Español Français
Awaiting validation
This guide explains how to configure and use various SAS© engines via the LIBNAME statement to interact with different data types and environments. It covers assigning the default V9 engine, using the SPD engine for performance, integration with Hadoop, preventing character truncation with the CVP engine during encoding changes, and loading data to a CAS server for in-memory analysis. Each example is designed to be standalone and illustrates key concepts for effective SAS© programming on the SAS© Viya 4 platform.
Data Analysis

Type : CREATION_INTERNE


Examples use generated data (DATA STEP from SASHELP.CLASS or SASHELP.CARS) or library assignments that assume the availability of standard SAS data (SASHELP) or specific environments (Hadoop, CAS) with their own data.

1 Code Block
LIBNAME / DATA STEP Data
Explanation :
This LIBNAME statement assigns the libref 'myfiles' and the V9 engine to a library location. Replace 'library-path' with your library's path. The location must exist and be accessible by the SAS compute server. The DATA step creates the 'myclass' dataset in the 'myfiles' library by copying the 'class' dataset from the 'sashelp' library.
Copied!
1LIBNAME myfiles v9 'library-path';
2DATA myfiles.myclass;
3 SET sashelp.class;
4RUN;
2 Code Block
LIBNAME
Explanation :
This LIBNAME statement assigns the libref 'mylib' and the SPD engine to a primary path. The metadata file is stored in this primary path. The DATAPATH= option allows assigning one or more paths to store data partitions. The INDEXPATH= option allows assigning one or more paths to store index files.
Copied!
1LIBNAME mylib spde 'library-path'
2datapath=('path-for-
3data-partitions')
4indexpath=('path-for-indexes');
5 
3 Code Block
OPTIONS / LIBNAME
Explanation :
The SET= options define environment variables for Hadoop. The LIBNAME statement assigns the libref 'mydata' to the SPD engine and to a directory in the Hadoop cluster. The HDFS=YES argument specifies the connection to the Hadoop cluster. The ACCELWHERE=YES option requests that data subsetting be performed by a MapReduce program in the Hadoop cluster.
Copied!
1options SET=SAS_HADOOP_CONFIG_PATH='/myconfigpath';
2options SET=SAS_HADOOP_JAR_PATH='/myjarpath';
3 
4LIBNAME mydata spde '/data/abcdef' hdfs=yes accelwhere=yes;
4 Code Block
LIBNAME / PROC COPY / PROC CONTENTS Data
Explanation :
The first LIBNAME statement assigns the 'srclib' library to the CVP engine and to the location of the data to be copied. The CVPENGINE= option specifies the V9 engine as the underlying engine. The CVPMULT=2.5 option multiplies the length of all character variables by 2.5. The second LIBNAME statement assigns the 'target' library. The COPY procedure copies the 'myclass' dataset to the 'target' library, extending the lengths of the character variables. The CONTENTS procedure displays the new lengths of the character variables.
Copied!
1LIBNAME srclib cvp 'library-path-1' cvpengine=v9 cvpmult=2.5;
2LIBNAME target v9 'library-path-2';
3PROC COPY in=srclib out=target;
4 select myclass;
5RUN;
6 
7PROC CONTENTS DATA=target.myclass;
8RUN;
5 Code Block
CAS / LIBNAME / DATA STEP / PROC CONTENTS Data
Explanation :
The CAS statement starts a CAS session and specifies 'casauto' as the CAS session name. The LIBNAME statement assigns the libref 'mycas' to the CAS engine, using the 'casauto' session. The DATA step copies the SAS dataset 'sashelp.cars' to the CAS session. The PROMOTE=YES dataset option promotes the table with global scope. The CONTENTS procedure shows that the 'mycas.cars' table is available on the CAS server.
Copied!
1cas casauto host="cloud.example.com" port=5570;
2 
3LIBNAME mycas cas;
4DATA mycas.cars (promote=yes);
5 SET sashelp.cars;
6RUN;
7PROC CONTENTS DATA=mycas.cars;
8RUN;
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


Related Documentation : SAS Engines

Sujet / Mot-cléLien vers la ressource
DOC Characteristics of SAS Engines en/sampleCode/CHARAC9D9D
Banner
Expert Advice
Expert
Michael
Responsable de l'infrastructure Viya.
« On the SAS Viya 4 platform, the LIBNAME statement is much more than a simple file pointer; it is a configuration tool that dictates how SAS interacts with the underlying storage architecture. Choosing the correct engine is the single most important decision for balancing performance, scalability, and data integrity. »