Copying a Data Set from One Library to Another Library

The %CSTUTILADDDATASET macro copies a data set from one library to another library.
In this example, the _cstInputDS parameter contains the libname.dataset to copy (the source). The _cstDS parameter contains the libname.dataset to create (the target). Key variables for the newly created data set are specified in the _cstDSKeys parameter.
*************************************************
*  Copy a data set from one library to another  *
*************************************************;

libname newstudy '<directory where new study data sets will reside>';
libname srcmeta '<directory supplying data set to be copied>';
libname log 'C:\cstGlobalLibrary\logs';

%cstutiladddataset(
        _cstStd=CDISC-SDTM,
        _cstStdVer=3.1.3,
        _cstDS=newstudy.source_values,
        _cstInputDS=srcmeta.source_values,
        _cstDSLabel=SDTM Source Value Metadata,
        _cstDSKeys=sasref table column value,
        _cstOverwrite=Y);
In this example, newstudy.source_values (_cstDS parameter) is a copy of the data set from srcmeta.source_values (_cstInputDS parameter). A label (_cstDSLabel parameter) is specified for newstudy.source_values with the value SDTM Source Value Metadata. Data set key variables (sasref, table, column, and value) are specified in the _cstDSKeys parameter. The _cstOverwrite parameter is set to Y, which allows an existing copy of this data set to be overwritten.
Before running the macro, the Newstudy library is empty. After running the macro, the data set from the Srcmeta library is copied to the Newstudy library.
The SAS log file contains a message to inform you that the operation was successful:
[CSTLOGMESSAGE.CSTUTILADDDATASET] NOTE: newstudy.source_values successfully added.
Note: If the message is not in the SAS log file, review the contents of the work._cstresults data set.
The following display shows that the properties of the newstudy.source_values data set show that the keys and label parameter values were used:
Keys and Label Parameter Values Were Used
keys and label parameter values were used
The following display shows part of the transaction log data set in the Log library, which shows that it was updated:
Transaction Log Data Set Was Updated
transaction log data set was updated
Note: Not all of the columns are shown.