1. Home
  2. TX2VARIATE directive

TX2VARIATE directive

Converts text structures to variates.

Options

PRINT = string token Controls printed output (conversions) ; default * (i.e. none)
NONNUMERIC = string token How to treat non-numeric values (bestmatch, missing) default miss

Parameters

TEXT = texts Text structures to convert
VARIATE = variates Variate for each text, containing the numbers in each of its lines
DREPRESENTATION = scalars Format to use for dates and times (stored in numerical structures)
MISSING = texts Strings used to represent missing values in each text; default ‘*’
STATUS = variates Code to indicate whether the number in each unit was read successfully (1), or with conversions (2), or unsuccessfully (0)

Description

The TX2VARIATE directive converts texts to variates. The texts are specified by the TEXT parameter, and are assumed to contain a single number in each of their strings. The variates are specified by the VARIATE parameter. The MISSING parameter specifies a text for each text and variate, containing the string or strings that should be treated as missing values in the conversion; by default this is the string containing a single asterisk. Blank and null lines are always treated as missing.

By default, any non-numeric strings generate a missing value in the variate. However, you can set option NONNUMERIC=bestmatch to ignore commas, and to allow for the common typing errors that the letters i or l may have been typed instead of i, or that the letters o or O may have been typed instead of 0. You can set option PRINT=conversions to print a list of the values that have been converted. Also, the STATUS parameter can save a variate with a code for each number to show whether it was read successfully with no conversions (1), or only with conversions (2), or whether it could not be read successfully (0).

Options: PRINT, NONNUMERIC.
Parameters: TEXT, VARIATE, MISSING, STATUS.

Action with RESTRICT

TX2VARIATE takes account of restrictions on each TEXT or VARIATE. The values of the VARIATE in the units excluded by the restriction are left unchanged.

See also

Directives: TEXT, READ.
Commands for: Calculations and manipulation.

Example

" Example 1:4.5.3 "
TEXT       [VALUES=' 0.01',' -1','2.2','3.3E1',il,'-IO',O,'1,001',\
           ' ','*','notnumber!','3.3D2','1.23E-4','-1.23E'] Textvals
TX2VARIATE [PRINT=conversions; NONNUMERIC=bestmatch] Textvals;\
           VARIATE=Realvals; Status=Status
PRINT      Textvals,Realvals,Status; DECIMALS=*,6,0
TEXT       [VALUES='1/12/01','27/1/02','1/1/03','28/7/04','16/11/08',\
            '4/7/14','11/5/15','21/10/16','12/3/17','3/4/17'] Tdate
TX2VARIATE Tdate; VARIATE=Vdate; DREPRESENTATION=3
PRINT      Tdate,Vdate,Vdate; DREPRESENTATION=0,0,3
Updated on September 12, 2019

Was this article helpful?