The %CSTUTILAPPENDMETADATARECORDS
macro adds new records to a data set. This macro requires an input
data set that contains the records to use to update the target data
set. It takes records from the input data set and either appends or
merges the records to the target data set.
Note: Appending records to a data
set always adds rows to the target data set even if the rows already
exist in the target data set. Merging records adds new rows and updates
existing rows. If keys are present, the target data set is sorted
and duplicate key records are deleted.
In this example, the
newstudy.source_values data set is merged (indicated by _cstUpdateDSType=merge
)
with the work.newrecs data set. The _cstOverwriteDup parameter enables
duplicate records from work.newrecs to overwrite those records in
newstudy.source_values.
*****************************
* Merge in the dummy data *
*****************************;
%cstutilappendmetadatarecords(
_cstStd=CDISC-SDTM,
_cstStdVer=3.1.3,
_cstDS=newstudy.source_values,
_cstNewDS=work.newrecs,
_cstUpdateDSType=merge,
_cstOverwriteDup=y,
_cstTestMode=n);
Note: To merge successfully, the
keys for the data sets must match. Any discrepancies in the keys are
reported either to the SAS log file or to the Results data set.
Before running the macro,
the work.newrecs data set was created for the _cstNewDS macro parameter.
Note: The data set (newstudy.source_values)
must share the same structure as the target data set (work.newrecs).
The row count (
Rows)
is increased from 28 to 30 (
compare
to the image ), which indicates that the two records were added from
the work.newrecs data set.
The results of running
the macro write to the work._cstresults data set because the data
set was created by the macro in the previous example.
Note: Not all columns or rows are
shown.
Note: Not all columns or rows are
shown.
In this example, the
newstudy.source_values data set is appended (indicated by _cstUpdateDSType=append
)
to the work.newrecs data set. When appending rows, the _cstOverwriteDup
parameter is ignored.
***************************
* Append the dummy data *
***************************;
%cstutilappendmetadatarecords(
_cstStd=CDISC-SDTM,
_cstStdVer=3.1.3,
_cstDS=newstudy.source_values,
_cstNewDS=work.newrecs,
_cstUpdateDSType=append,
_cstOverwriteDup=y,
_cstTestMode=n);