Skip to content

Language: Select Statement

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

Select data from a data frame based on criterion, make the selected data as a new data frame, and attach the newly formed data frame for use.

Syntax:

  1. SELECT FROM ID AS ID: Select all data from a data frame into another data frame, which is essentially replicating a data frame.

  2. SELECT FROM ID AS ID WHERE binop value: Select data from a data frame into another data frame, where a data element in any series, identified by the same data label, holds true for the selection criterion.

  3. SELECT FROM ID AS ID WHERE ID binop value: Select data from a data frame into another data frame, where a data element in a specific series, holds true for the selection criterion.

where

  • ID is the data frame name or series name
  • "binop" is the binary comparative operator. The following are allowed: "=" (equals to), "!=" (not equals to), ">" (more than), ">=" (more than or equals to), "<" (less than), "<=" (less than or equals to), and "*" (all, essentially matches everything)
  • "value" is the value to be matched against

Example:

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

# Case Open to float
cast Open in STI as nonalpha

# Duplicate STI as STI_D
select from STI as STI_D

# Select rows where Open > 3000, and load as STI_H
select from STI as STI_H where Open > 3000

# Select rows where Open < 820, and load as STI_L
select from STI as STI_L where Open < 820

# Select rows where any data element within a row is < 820, and load as STI_800
select from STI as STI_800 where < 800

Advanced Topics

  1. Bytecodes generated are:
    • duplicateframe
    • greedysearch
    • idsearch