TABLE OF CONTENTS
- IVS - Definition section
- IVS - Field Definitions section
- IVS - User Definitions section
- IVS - Field Groupings section
- IVS - Field Recode section
A source definition file (IVS) defines the format of a table's source file and, in the case of an ASCII file, describes its layout. The IVS also contains information about series definitions, user-defined fields, and redefinition fields.
IVS - Definition section
The mandatory Definition section of an IVS specifies the version of the IVS, the filter module that will be used to process the source file, and the field definitions (lengths of the records) for ASCII source files.
Beyond 20/20 uses three kinds of source files:
- ASCII (fixed record text)
- DBF (dBase file format)
- CSV (Comma-separated values)
DBF and CSV files do not need field definitions, because the field information is contained within the files themselves.
The following describes the key entries in the definition section of an IVS:
Key | Required | Description |
RecLen | Required for ASCII source files. | The length (in characters) of each record in a fixed-length ASCII source file. Used to locate individual records. If an ASCII source file contains no binary fields, RecLen may have one of the following values instead of a length: AutoCR – Identifies the start and end of records by scanning the source file for carriage returns. AutoLF – Identifies the start and end of records by scanning the source file for line feeds. AutoCRLF – Identifies the start and end of records by scanning the source file for carriage return/line feed pairs. |
Filter | Yes | The filter module that will be used to process the source file. Possible values are: IVTEXT.DLL – for ASCII files IVDBASE.DLL – for dBase files IVCSV.DLL - for CSV files |
Version | Yes | The version of the IVS. Possible values are: 1 – The IVS is in the OEM character set. Missing values are defined using the Beyond 20/20 version 4.1 method. 2 or greater – The IVS is in ANSI format. Missing values are defined using the version 5.2 method. 3 – Adds support for the Lookup field in the Field Definitions section. Note that the version entered here determines which method you are able to use for defining missing values. See Field Definitions for more information about the two methods of defining missing values. |
Example
This Definition section of an IVS file specifies that the source file is a fixed length ASCII text file that uses the ANSI character set. Its records are delimited by carriage return/line feed pairs.
[Definition] RecLen=AutoCRLF Filter=IVTEXT.DLL Version=2
IVS - Field Definitions section
The Field Definitions section of an IVS defines all the fields in an ASCII source file. (Only used for ASCII files. DBF and CSV files do not need field definitions because they contain their own field information.)
The syntax for a field definition is as follows:
Fieldname=DataType,Start,Width[,DateFormat,Treatment,DefinitionFile,Description,Periodicity,Decimals,Category,MissingValues,LookupField]
Fieldname is the name of the source field. Field names can use any characters, including spaces, but ideally they should begin with a letter and all the other characters should be either letters or numbers. The maximum length of a field name is 15 characters.
Only DataType, Start, and Width are required values, with the following exceptions:
- If the data type is Date, DateFormat must be defined.
- If the data type is Zoned, Decimals must be defined.
The commas (and no spaces) between the values are required. Note that if one or more undefined fields precede a defined field, you must mark the places for the undefined fields with empty comma pairs (",,"). However, comma pairs are not required for undefined fields that fall at the end of their code string.
The following table describes the values in the Field Definitions section of an IVS:
Key | Required | Description |
DataType | Yes | |
Start | Yes | |
Width | Yes | |
DateFormat | Yes, if the data type is Date. | Possible formats are: "d" – A day, expressed as a one or 2-digit number. E.g. 1, 2, or 12. "Dd" – A day, expressed as a 2-digit number. E.g. 01, 02, or 12. "m" – A month, expressed as a one or 2-digit number from 1 to 12. E.g. 4, 7, or 11. "Mm" – A month, expressed as a 2-digit number from 01 to 12. E.g. 04, 07, or 11. "Mmm" – A month, expressed as a 3-letter short form. E.g. Jan, Jul, or Nov. "Yy" – A year, expressed as a 2-digit number. E.g. 77, 39, or 01. (This assumes a range from 1950 to 2049.) "Yyyy" – A year, expressed as a 4-digit number. E.g. 1977, 2001, or 3062. "p" – A period, expressed as a single digit from 1 to 4. Used to specify the period for semi-annual and quarterly series. For example, a period of 1 could mean either the first half or the first quarter of a year. |
Treatment | No | The way the Builder will treat the data in a source field. Used when creating extracts. Possible values are: Numeric – A number that can be used in calculations. Dated – A calendar date. If no date format is specified, the date must be stored in a standard Beyond 20/20 date format. See Date Formats (300). Coded – Data is neither numeric nor dated. Ignored – Data will not be included in the extract. |
DefinitionFile | No | Identifies an IVD, IVN, or CSV file that will be used as the dimension definition file for the source field. If no path is given, the dimension definition file is assumed to be located in the same folder as the IVS. If used, the Field name, Description, and Category that are stored in the dimension definition file override the Field Name, Description, and Category that are stored in the source definition file. |
Description | No | A description of the source field. Maximum length = 255 characters |
Periodicity | No | The frequency of the data in a date field. Possible values are: Annual Semi-Annual Quarterly Monthly Weekly Daily |
Decimals | Yes, if the data type is Zoned. | The number of places the decimal is to be moved to the left in a numeric string. Moving the decimal to the left divides a numeric string by an amount represented by the number of decimals. For example, moving the decimal one place to the left divides the value by 10; moving it two places divides the value by 100; moving it three places divides the value by 1000; and so on. The number of decimal places can be negative, in which case the decimal is moved to the right and the value is multiplied instead of divided. This can be useful to provide scaling (for example, GNP in thousands of dollars); however, handling numbers in this way results in a loss of precision. |
Category | No | Used only when creating an extract. A category that is assigned to the source field by default. Maximum length = 255 characters. |
MissingValues | No | Defines how missing values in the source field are treated. Missing values are treated differently in Beyond 20/20 version 5.2 and later versions than in earlier versions such as 4.1. See the following for more information about the MissingValues entry in a source definition file. |
Lookup | No | Version 3.0 and later. If a definition file is specified in this record, this refers to the dimension field that is to be used as the lookup field for building tables and extracts. If not specified, the Code (or Timeseries) field will be used. |
MissingValues
A missing value is a value that is either not present in the source file, or that is present but is defined as
being “missing.” Missing values can be indicated by blank cells or by zeros or other characters.
Treatment of missing values differs between Beyond 20/20 version 4.1 and version 5.2. Both treatments are described below:
An example of a field definition that includes a missing value definition follows:
Income=Numeric,11,4,,,,,,,, =1;99999=2;-99998=3;NULL
- As in the example for version 4.1, Income is the field name. Its type is Numeric, it starts at the 11th character, and its width is 4 characters. The seven empty comma spaces represent undefined optional values.
- The final four entries assign missing value definitions to the numeric keys "1," "2," and "3."
- A blank space of any length in a field refers to the missing value definition that corresponds to the numeric key "1."
- "99999" refers to the missing value definition that corresponds to the numeric key "2."
- "-99998" refers to the missing value definition that corresponds to the numeric key "3."
- Because NULL has no qualifier, it defaults to the numeric key "1."
IVS - User Definitions section
The optional User Definitions section of an IVS can be used in three ways:
- To define a field whose value is constant.
- To extract a value from a filename.
- To redefine a field's type in a dBase file.
The syntax for entries in this section is as follows:
Fieldname=Type,Value[,DateFormat]
- Fieldname is the name of a user-defined source field. Field names can use any characters, including spaces, but they should begin with a letter and all the other characters should be either letters or numbers. Following this rule makes it easier to specify derived fields, constraints, and other calculations. The maximum length of a field name is 15 characters.
The values in the User Definitions section of an IVS are described below:
Key | Required | Description |
Type | Yes | The source field’s data type. Possible values are: Character – any ASCII characters. Date - A date field stored as ASCII characters. Requires a value for DateFormat (below). |
Value | Yes | Either a constant value or a field name. A constant value is used to assign a single value to a field for the entire file. See Constant Value, below. A field name is used to redefine a dBase field that is not stored in the proper format. Field names must be enclosed in square brackets. See Field Names, below. |
DateFormat | Required if the data type is Date. | Possible date formats are: d – A day, expressed as a one or 2-digit number. (E.g. 1, 2, or 12.) Dd – A day, expressed as a 2-digit number. (E.g. 01, 02, or 12.) m – A month, expressed as a one or 2-digit number from 1 to 12. (E.g. 4, 7, or 11.) Mm – A month, expressed as a 2-digit number from 01 to 12. (E.g. 04, 07, or 11.) Mmm – A month, expressed as a 3-letter short form. (E.g. Jan, Jul, or Nov.) Yy – A year, expressed as a 2-digit number. (E.g. 77, 39, or 01. Assumes a range from 1950 to 2049.) Yyyy – A year, expressed as a 4-digit number. (E.g. 1977, 2001, or 3062.) "p" – A period, expressed as a single digit from 1 to 4. Used to specify the period for semi-annual and quarterly series. (For example, 1 = 1st half or 1st quarter.) |
Constant Value
A constant value is used when a field has one single value for the entire file.
In the following example, a constant value field has been created to help with processing monthly employee records. The field's code is Month, its type is Date, and its value is Aug2000. "mmmyyyy" is the date format that has been applied to the date Aug2000.
[User Definitions] Month=Date,Aug2000,mmmyyyy
Now when a table is built from this IVS, the value of the Month field will automatically be set to Aug2000.
Constant values can also be used to extract descriptive information that is not included within the record information. For example, while the above constant value field is useful in August 2000, the value of Month will have to be updated every month in the IVS in order to process the current employee records.
If the filename of the source file always contains the date, you can extract the date information from that name by defining filename parameters. Filename parameters act as placeholders for the actual information.
For example: If the file name of the file that contains the employee records is always EMPmmyy.dbf, where "EMP" stands for "Employee Records" and "mmyy" is the month and year, you can define the filename parameter: "???mmyy."
Now the following user-defined field definition will extract the date from the file name and insert it into the constant value field "Month."
[User Definitions] Month=Date,{month}{year},mmmyyyy
See help for Filename Parameters ( or 303 in the Builder User's Guide) for a list of possible variables.
Field Names
A field name (enclosed in square brackets) is used to redefine a dBase field that has been stored with the incorrect type, such as a date that does not conform to Beyond 20/20 standard date formats.
You can redefine the date field by defining a new field name (such as Date2). Define its type as Date and then include the old fieldname in square brackets as the value for the new field, as follows:
[User Definitions] Date2=Date,[DATE],yyyymmdd
- Date2 is the filename of a user-defined field.
- The Type of date2 is Date and its format is yyyymmdd.
- The value of Date2 is [DATE], which refers to an existing but wrongly-formatted DBF field.
Now Date2 will derive its data from the DBF field DATE and will format it correctly as a Beyond 20/20 Date field.
IVS - Field Groupings section
The Field Groupings section of an IVS defines a series field. A series field is a group of fields that can be displayed together in a table as one dimension.
The syntax to define a series field is as follows:
FieldName=CodeValue,SourceField,Override
FieldName is the name of a field that is to be defined as a series field.
The following describes the values in the Field Groupings section of an IVS:
Key | Description |
CodeValue | The code for an item in a series. Becomes the code for the item in the dimension. CodeValue can use filename parameters. |
SourceField | The name of a field (defined in [FieldDefinitions]) which will be used as input for the series item. |
Override | In a series field, used if the data in SourceField is not defined as being of the type numeric. Values for Override are: Numeric Boolean |
Example
The following is the Field Groupings section of an IVS file. It creates a series field called "Year" that contains data for both 2000 and 2001.
[Field Groupings] Year=2000,00,Numeric Year=2001,01,Numeric
- Year is the name of the newly-defined series field.
- 2000 and 2001 are codes for the two items in the series.
- 00 and 01 are the source fields that contain the values for 2000 and 2001.
- Data for use in series fields must be numeric or boolean. If it is not, its type can be overridden. In this example, Numeric overrides the former type of the data in the year source fields, which was Character.
IVS - Field Recode section
The Field Recode section of an IVS is used to define a redefinition field so you can convert a code from one value to another.
To redefine a field, first use Visual Builder to create an IVD that defines the following two fields:
- The Lookup Field, whose codes match the source codes that are to be converted.
- The Value Field, which contains the values that the codes will be mapped to.
Once you have created the IVD, the syntax to define a redefinition field is as follows:
FieldName=SourceField,LookupField,ValueField,Filename
The following describes the values in the Field Recode section of an IVS:
Key | Description |
SourceField | The field in the source file that contains codes that are to be converted. |
LookupField | The field in the IVD that matches the codes in the source file. |
ValueField | The field in the IVD that contains the new values for the codes in the source file. |
Filename | The name of the IVD that contains the redefinition information. |
Example
[Field Recode] Region=RegionCode,Code,NewCode,C:\B2020\Data\Region.ivd
- Region is the name of the new field that will be created.
- RegionCode is the source field - the field in the source file that contains the codes that are to be converted.
- Code is the lookup field - the field in an IVD that matches the codes in the source field.
- NewCode is the value field - the field in the IVD that contains the new values the codes will be mapped to.
- C:\B2020\Data\Region.ivd is the path to the IVD that contains the redefinition information.