Skip to content

Language: Merge Statement

Maurice HT Ling edited this page Dec 6, 2015 · 2 revisions

Merge an object into another object, or a series/label name from one data frame into another data frame.

Syntax:

  1. MERGE SERIES id_list FROM ID TO ID: Merging one or more series from one data frame into another. The end result will be an increase in series within the data frame.

  2. MERGE LABELS FROM ID TO ID: Appending new data (labels not found in the destination data frame) from a source data frame. The end result (destination data frame) may have appended data but the number of series (columns) remains the same.

  3. MERGE REPLACE LABELS FROM ID TO ID: Appending new data (labels not found in the destination data frame) from a source data frame. However, if the labels from the source data frame is/are found within the destination data frame, data with those labels in the destination data frame will be replace by the corresponding data from the source data frame. The end result (destination data frame) may have appended data but the number of series (columns) remains the same.

where

  • ID is the name of object or data frame
  • id_value is the name to be changed

Example:

# Set relative current working directory and load a CSV file
set rcwd data
load csv STI_2015.csv as STI

# Replicate STI as LSeries and LLabels
select from STI as LSeries
select from STI as LLabels

# Renaming 'Open' series in STI from 'Open' to 'OpenDup'
rename series in STI from Open to OpenDup

# Merge OpenDup from STI into LSeries
# Essentially, Open and OpenDup in LSeries will have the same data (by labels)
merge series OpenDup from STI to LSeries

# Renaming '1/11/1988' label in STI from '1/11/1988' to 'dummydate'
rename labels in STI from '1/11/1988' to dummydate

# Append STI to LLabels
# Essentially LLabels will have 1 row more than STI
merge labels from STI to LLabels

Advanced Topics

  1. Bytecodes generated are:
    • mergeseries
    • mergelabels1
    • mergelabels2