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!
libname myfiles v9 'library-path';
data myfiles.myclass;
set sashelp.class;
run;
1
LIBNAME myfiles v9 'library-path';
2
DATA myfiles.myclass;
3
SET sashelp.class;
4
RUN;
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.
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.
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.
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!
cas casauto host="cloud.example.com" port=5570;
libname mycas cas;
data mycas.cars (promote=yes);
set sashelp.cars;
run;
proc contents data=mycas.cars;
run;
1
cas casauto host="cloud.example.com" port=5570;
2
3
LIBNAME mycas cas;
4
DATA mycas.cars (promote=yes);
5
SET sashelp.cars;
6
RUN;
7
PROC CONTENTSDATA=mycas.cars;
8
RUN;
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.
« 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. »
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.