HomeStartingEnvironmentDBMSVisualPQLProceduresSQLFormsHost/APIIndex
Database homecontents start chapter top of pagebottom of pagenext page index Schema

Schema Commands

There are commands to
create a new database or to connect an existing database. Passwords can be supplied with the PASSWORD command. Attaching a database and supplying passwords is normally done through menus or with the Execution Parameters.

There are numerous commands to define the specific features of a database. A set of commands that corresponds to the definition of the attached database can be written to a file using WRITE SCHEMA and edited. The schema definition can then be executed as any other SIR/XS procedure.

A report on the definition of the attached database can be produced with the SCHEMA LIST command.

The complete database can be deleted. Individual record definitions can be deleted provided that there is no data for that record.

The format of schema commands is the same as other SIR/XS commands, that is new commands must begin at the start of a line and continuation lines for a command must have blanks at the start of the line. Individual clauses within a command may be separated by slashes for readability.

All changes to a database, including schema changes, are recorded on the journal file provided that journaling is on. Initial schema definition before any data is added to a database is not journaled. Once there is data in the database, each schema modification run increments the update level of the database.

Overall database commands precede record definition commands. There may be many sets of record definition commands (one set for each record type) and, within a record definition, there is an order for the various types of commands.

Secondary index definitions may follow a record definition. A secondary index is defined with a single CREATE DBINDEX command. These can be done before or after any initial data loading. Defining an index builds the index automatically if there is existing data in the record.

Overall Commands

The overall database commands specify whether there is a case structure, size estimates, security, and any documentary text. The commands are:

[NO] CASE ID

Defines whether this database has a case structure or is a caseless database. This is the only required command to define a database.

DATA FILES

Specifies a data file that is non-standard. This may have a different name, be in a different directory or may be split across multiple files.

DATABASE LABEL

Specifies a descriptive label of up to 78 characters for the database.

DOCUMENT

Stores text about the database in the data dictionary.

ENCRYPT [ON|OFF}

Defines whether data in this database is encrypted or not.

MAX INPUT COLS

Specifies the longest batch input record length.

MAX KEY SIZE

Specifies the maximum key size.

MAX REC COUNT

Specifies maximum number of records of one type.

MAX REC TYPES

Specifies maximum number of record types.

N OF CASES

Specifies maximum number of cases for case structured databases.

N OF RECORDS

Specifies maximum number of records for caseless databases.

READ SECURITY

Sets security passwords for read access levels.

RECS PER CASE

Specifies the average number of records per case.

RECTYPE COLS

Specifies the columns that contain the record type for Batch Data Input.

SYSTEM SECURITY

Sets security passwords for specific DBA utilities.

SYSTEM SECURITY LEVEL

Sets the security level for specific DBA utilities.

TEMP VARS

Specifies temporary variables used during Batch Data Input.

WRITE SECURITY

Sets security passwords for write access levels.

Record Definition

The record definition commands specify the name and number of the record, the key fields and any documentary text together with the name, type, and size of each variable. A further set of information may be specified that relates to the Batch Data Input utilities. This specifies how data is loaded from serial files, including any computations and logical accept/reject clauses.

Sometimes the same data with the same coding scheme appears on multiple record types. For example standard drug codes or states in a country. Rather than repeating definitions in multiple record types, a standard schema can be defined that contains all of the descriptions and codes for the variable and it can then simply be included as a standard var in records as necessary.

In a case structured database, a set of variables can be held at the case level in the CIR. Specify variables that are in the CIR with a RECORD SCHEMA 0 CIR record definition.

Within a record definition, there is an order for commands. The example record definition shows some of the most commonly used record definition commands.

The following commands are used to specify records.

ACCEPT REC IF

Specifies acceptance tests for batch data input.

CAT VARS

Specifies variables are categorical.

CHARACTER*n

Defines new character variables and their length. n may be from 1 to 4094.

COMPUTE

Specifies computations in batch data input.

CONTROL VARS

Specifies that numeric variables are control variables not observation variables. By default, numeric variables defined with a set of VALID VALUES or VALUE LABELS are control variables. To specify other numeric variables as control variables, define a VAR RANGE for them.

DATA LIST

Defines the complete set of variables in the record with any appropriate external formats and positions for batch data input.

DATE VARS

Specifies variables are date variables and defines the external date format.

DOCUMENT

Stores text about the record in the data dictionary.

END SCHEMA

Specifies the end of this record definition.

IF

Computes values conditionally in batch data input.

INPUT FORMAT

Specifies the external format of variables defined by the VARIABLE LIST.

INTEGER*n

Defines new integer variables with an internal length of 1, 2 or 4.

KEY FIELDS

Specifies the variables that are keys for a record.

MAX REC COUNT

Specifies the number of records of this type that can be held.

MISSING VALUES

Specifies missing values for variables.

OBSERVATION VARS

Specifies that numeric variables which have valid values or value labels are observation variables instead of control variables.

REAL*n

Defines new floating point variables with an internal length of 4 or 8.

REC SECURITY

Sets default security levels for variables in this record.

RECODE

Specifies recodes performed by batch data input.

RECORD SCHEMA

Begins the record definition and names the record. It can include a record label.

REJECT REC IF

Specifies acceptance criteria for batch data input.

SCALED VARS

Specifies integer variables are scaled and defines the scaling factor.

TIME VARS

Specifies variables are time variables and defines their external format.

VALID VALUES

Defines valid values for variables.

VALUE LABELS

Defines value labels for variables.

VARIABLE LIST

Defines variables. Used with INPUT FORMAT as alternative to DATA LIST.

VAR DOC

Defines documentation for variables.

VAR LABEL

Defines a label for variables.

VAR RANGES

Defines ranges of valid values for variables.

VAR SECURITY

Defines read and write security levels for individual variables.

homecontents start chapter top of pagebottom of pagenext page index

Modifying Database Definitions

The database definition can be modified through the menus. If using commands to modify the schema, you use the normal RECORD SCHEMA command to make specific changes. If a definition exists for a record and you do not submit a new DATA LIST command, then you are modifying the schema. If you do submit a new DATA LIST then you must re-submit the entire schema.

The ADD VARS, MODIFY VARS and DELETE VARS are equivalent to a DATA LIST when modifying a schema and have the same syntax.

If the STANDARD SCHEMA is modified, then all record types that have any STANDARD VARS are updated to reflect the changes. If a standard variable definition has been deleted, then standard variables that referenced that deleted variable are no longer standard variables.

There are a number of commands that are only applicable when modifying an existing record definition. Except as documented below, commands completely replace any existing definition.

ADD VARS

Adds new variables to the variable list.

CLEAR BOOLEANS

Clears all ACCEPT/REJECT conditions.

CLEAR COMPUTES varname1,... | ALL

Clears all computes for the specified variable(s).

CLEAR RECODES varname1,... | ALL

Clears all recodes of the specified variable(s).

CLEAR VALUE LABELS varname1,... | ALL

Clears all value labels for the specified variables.

CLEAR VAR DOC varname1,... | ALL

Clears all the lines of documentation for the specified variables.

CLEAR VAR LABEL varname1,... | ALL

Clears the label for the specified variables.

COMPUTE

Defines new compute definitions. These are added to the old definitions. Use the CLEAR COMPUTES command to delete old COMPUTE definitions.

DELETE VARS

Deletes variables from the variable list.

EDIT LABELS

Edits the value label list for the specified variables. This command has the same format as the VALUE LABELS command. Any new values are added to the list, any existing values that are referenced are updated. Existing value labels that are not referenced are not altered.

MODIFY VARS

Modifies the type, external format or batch data input position of existing variables.

RENAME VARS existing_variable_list {AS new_variable_list | PREFIX 'text' | SUFFIX 'text'}

Renames one or more variables while keeping all existing definitions of the renamed variable(s). The variables to be renamed are specified as a list and this can use the ALL or TO keywords. The new names can be specified individually as a list (which can also use the TO keyword), in which case there must be the same number of variable names in both lists. Alternatively the new names can be constructed by appending a prefix or suffix. If a prefix or suffix is specified, enclose the text in quotes. Note that this text is used exactly as specified so ensure that the correct case is used. Appending a prefix or suffix can result in non-standard names. The resulting names must fit within the 32 character limit on names.

Examples:

RECORD SCHEMA 1
EDIT LABELS JOBCODE  (21) Salesperson
                     (22) Senior Salesperson
                     (23) Sales Manager/
VAR RANGES JOBCODE (1 23)
The following example adds two variables to the Employee record type.

RECORD SCHEMA 1, EMPLOYEE
ADD VARS    ETYPE 70  (I)/
            PHONE 71 - 80 (A)
VAR RANGES  ETYPE (1 3)
VAR LABEL   ETYPE 'Employee Type'/
            PHONE 'Home Phone Number'/
END SCHEMA
The following example modifies the variable label for Position and the variable label for value 5 of Rating in the Review record type.
RECORD SCHEMA 3, REVIEW
VAR LABEL    POSITION   'Job Code'
EDIT LABELS  RATING (5) 'Excellent'
END SCHEMA

Note: if you do two EDIT LABELS for the same variable in the same RECORD definition, only the effect of the final one will be applied. The original labels are reloaded for each EDIT.

homecontents start chapter top of pagebottom of pagenext page index

Format of Commands

Start new schema commands in column 1. Continue commands by leaving column 1 blank. Comments and general listing control statements can appear between any commands but not between the clauses of a single command.

When the same command applies to several variables, you can specify multiple variables and definitions on a single command. You can optionally delimit the specifications for each variable with a slash for readability. For example,

VALID VALUES CODE1 (1 2 3)
             CODE2 (1 2)
VALUE LABELS CODE1 (1) 'Tested'
                   (2) 'Preliminary'
                   (3) 'Passed'
             CODE2 (1) 'Domestic'
                   (2) 'Overseas' 

TO Lists

When defining variables, you can define a set of variables by using a pair of identical variable names with a numeric suffix in ascending sequence separated by the keyword word TO. For example, to define ten variables named VAR01, VAR02, ... VAR10:

VARIABLE LIST VAR01 TO VAR10

Once variables have been defined, they can be referenced as a list in other commands by using a pair of variable names separated by the word TO, regardless of the format of the variable names. The sequence of the variables included in the list is determined by the sequence in which the variables were defined. The TO list is inclusive and backwards references are not allowed. For example, suppose the following variables were defined on a variable list:

VARIABLE LIST ID EMPNO NAME STATUS1 TO STATUS3 GENDER

A reference on another command (such as MISSING VALUES) might be ID TO GENDER to include all the variables, or NAME TO STATUS3 to include NAME and the three STATUS fields. For example:

MISSING VALUES EMPNO TO GENDER (BLANK) The keyword ALL can be used to reference all of the variables in a record type.

homecontents start chapter top of pagebottom of pagenext page index

Order of Commands

Record definition commands follow database definition commands. The record definition commands of each record occur together. You do not have to define records in any particular order however define any standard schema as part of the database definition, immediately followed by RECORD SCHEMA 0 CIR for the common vars on a case structured database.

The KEY FIELDS command and the DATA LIST or INPUT FORMAT / VARIABLE LIST can only occur once per record. Other commands may occur multiple times.

Within each record, there is a general order that must be followed. The commands to do with the overall record structure come first, then the definition of the variables and then additional specifications referring back to the defined variables. It is normal for the definition of all variables to precede the optional specifications for all variables, but this is not required. It is required that the definition of a particular variable precedes the specification for that variable.

GroupCommands
1RECORD SCHEMA *
DOCUMENT
KEYFIELDS/SORT IDS
MAX REC COUNT
REC SECURITY

2DATA LIST or
VARIABLE LIST/
INPUT FORMAT*
INTEGER VARS
REAL VARS
CHARACTER VARS

3CAT VARS
CONTROL VARS
DATE VARS
MISSING VALUES
OBSERVATION VARS
TIME VARS
SCALED VARS
STANDARD VARS
VALID VALUES
VALUE LABELS
VAR DOC
VAR LABEL
VAR RANGES
VAR SECURITY

4ACCEPT REC IF
COMPUTE
IF
RECODE
REJECT REC IF

5END SCHEMA

The * commands (RECORD SCHEMA and either DATA LIST or VARIABLE LIST/INPUT FORMAT) are mandatory and must be supplied. All other commands are optional.

homecontents start chapter top of pagebottom of pagenext page index

Example Record Specification

The typical definition of a record with no batch data input processing consists of :

RECORD SCHEMA
KEY FIELDS
DATA LIST or VARIABLE LIST/INPUT FORMAT
DATE VARS & TIME VARS
MISSING VALUES
VALID VALUES
VALUE LABELS
VAR LABEL
END SCHEMA.

For example:

RECORD SCHEMA 1,PATIENT
KEY FIELDS     ID
VARIABLE LIST  ID,LNAME,FNAME,DOB,SEX,STATUS
INPUT FORMAT   (I4,A40,A40,DATE'MM/DD/YYYY',I1,I1)
MISSING VALUES  LNAME to STATUS (BLANK)
VALID VALUES    SEX    (1,2)
                STATUS (1,2,3)
VALUE LABELS    SEX       (1) 'Male'
                          (2) 'Female'
                STATUS    (1) 'Inpatient'
                          (2) 'Outpatient'
                          (3) 'No Longer Attending'
VAR LABEL       ID        'Patient Id'
                LNAME     'Last Name'
                FNAME     'First Name'
                DOB       'Date of Birth'
                STATUS    'Current Status'
END SCHEMA

In the above example the following commands were used:

RECORD SCHEMA

Specifies the record number and name, and begins the specification of a record type.

KEY FIELDS

Specifies the key field variables for the record type in order from major to minor key. This immediately follows the RECORD SCHEMA command.

VARIABLE LIST
INPUT FORMAT

The VARIABLE LIST names the variables; the INPUT FORMAT defines the data type, size and format. The variable names are simply listed in the order they are to appear in the database, separated by blanks or commas. Variables are held in the order they are defined. The format specification is enclosed in parentheses and commas are used as separators. "I" specifies integers, "A" specifies alphanumeric. Date formats consist of the word DATE followed by a date format. See date formats for a complete description. Time formats consist of the word TIME followed by a time format. See time formats for a complete description.

MISSING VALUES

Up to three missing values may be specified for any variable. The keyword BLANK specifies that blank input is treated as missing. When the same value is to be assigned to a set of variables the variable list format can be used. This consists of the two variable names that define the start and end of the list and the word "to".

VALID VALUES

Valid values or ranges of valid values may be specified for variables. Values that do not match these and are not a valid missing value can never appear in the data. Attempts to store an invalid value result in the system missing value (undefined).

VAR LABEL

A variable label may be up to 78 characters and can be used instead of the name of the variable on screens, column headings on reports, etc.

VALUE LABELS

Value labels associate a label with a given value. The label can be displayed in place of the value. Value labels are up to 78 characters long. The specification for each variable may be separated by a slash for readability.

END SCHEMA

Ends a record schema definition set of commands.

homecontents start chapter top of pagebottom of pagenext page index

CREATE DATABASE

CREATE DATABASE database_name
        [JOURNAL  = {ON | OFF}]
        [PASSWORD = database_password]
        [PREFIX   = database_directory]

Creates a new database. (NEW FILE is a synonym.) A database name must be a valid SIR/XS a name. To connect to an existing database, use the CONNECT DATABASE command.

JOURNAL

Controls whether journaling is performed for the new database. The default is ON. Journaling can be turned on or off with the JOURNAL command

PASSWORD

Defines the database password for the new database. The password must be a valid SIR/XS name. Specifying this keyword lists the password in the output listing. The database password can be supplied with the PASSWORD command that does not list the password in the output listing. If a password is not defined for a database, the password is set to blank. If a database has no password, future connections to the database need not specify a password. The UNLOAD FILE utility can change the database name and password.

PREFIX

Specifies the database directory. If not specified, the database is created in the current directory.

homecontents start chapter top of pagebottom of pagenext page index

CONNECT DATABASE

CONNECT DATABASE database_name
        [JOURNAL  = {ON | OFF}]
        [PASSWORD = db_password]
        [PREFIX   = database_directory]
        [SECURITY = {read_pw | *} [{write_pw | *}]]
        [CREATE]

Connects the specified existing database. (OLD FILE is a synonym.) A database must be connected before it can be used. The last connected database is the default database. Al processes and utilities run on the default database.

A pre-compiled VisualPQL program can connect a database when it runs, but, if you need to compile a VisualPQL program that references a database, the database must be connected first.

JOURNAL

Turns journaling on or off. Journaling is a database characteristic and remains as it was last set and need not be re-specified.

PASSWORD

Specifies the password that is required to access to the database. This is not required if the database has no password. This option shows the password in the output listing.

The database password can be supplied with the PASSWORD command that does not list the password in the output listing.

PREFIX

Specifies the database directory. This is not required if the database is in the current directory.

SECURITY

Specifies the read and write security passwords.

It is only necessary to specify the write security password when updating the database. To specify a write password when the read password is null, specify the read password as an asterisk (*).

If the read password matches the highest (30) level of security, then the user has Data Base Administrator (DBA) level access to the database and can run all utilities. If the database does not have any read passwords assigned, then any connected user has DBA access. See READ SECURITY

CREATE .

Creates a new database when used with the CONNECT DATABASE command. CREATE makes CONNECT DATABASE act identically to the CREATE DATABASE command.

homecontents start chapter top of pagebottom of pagenext page index

DISCONNECT DATABASE

DISCONNECT DATABASE database_name
Disconnects a database. If this is the default database, the procedure file is set to SYSPROC.

homecontents start chapter top of pagebottom of pagenext page index

SET DATABASE

SET DATABASE database_name
Sets a previously connected database as the default.

SHOW DATABASE

SHOW DATABASE
Writes a viewable list of connected databases.

LIST DATABASE

LIST DATABASE
Sends a list of connected databases to the OutputHandler callback routine in SirAPI when running in that mode.

homecontents start chapter top of pagebottom of pagenext page index

JOURNAL ON|OFF

JOURNAL ON|OFF

Turns journaling on or off. Journaling is a database characteristic and it is recommended that journaling is left on under normal circumstances.

homecontents start chapter top of pagebottom of pagenext page index

PASSWORD

PASSWORD database_password

Supplies the database password.

If this command immediately follows either the CREATE DATABASE (NEW FILE...) or CONNECT DATABASE (OLD FILE...) command. This means that the if the PASSWORD is to be specified then it MUST be on the next physical command line.

When used with CREATE DATABASE, this command defines the new database password.

When used with CONNECT DATABASE, this command supplies the password needed to connect the database. If the database has no password, this command need not be specified. If an incorrect password is specified, access to the database is denied.

If the PASSWORD command is used at any other time when a database is connected then it will change the database password.

This command does not print the password in the output listing.

homecontents start chapter top of pagebottom of pagenext page index

SECURITY

SECURITY read_pw , write_pw

SECURITY supplies the read and write passwords. If an incorrect password is specified, level 0 (zero) security is assigned.

This command does not print the passwords in the output listing.

homecontents start chapter top of pagebottom of pagenext page index

PURGE SIR FILE

Deletes the database. Use this utility to delete the current database before restoring it for recovery or restructuring. The database files are completely deleted from the disk.

PURGE SIR FILE
    [JOURNAL = KEEP | PURGE]
    [PROC    = KEEP | PURGE]
JOURNAL

KEEP specifies that the journal file is not deleted and is the default. PURGE specifies that the journal file is deleted when the database is deleted.

PURGE SIR FILE JOURNAL = PURGE

PROC

KEEP specifies that the procedures are not deleted. When a new database is created or a database is reloaded, the old procedure file can be used as part of that database. This keeps the procedures from a corrupt database when a restore cannot be accomplished. PURGE specifies that the Procedure File is deleted and is the default.

PURGE SIR FILE PROC = KEEP

homecontents start chapter top of pagebottom of pagenext page index

DELETE SCHEMA

Deletes the schema of a record that has no data. Select the appropriate record.

DELETE SCHEMA recname | recnum

Deletes the record schema name or number from the database definition. DELETE SCHEMA only operates if there are no records for this record type. This is a DBA security level command.

When defining and redefining a record type, it is sometimes simpler to DELETE SCHEMA and redefine it through a complete new RECORD SCHEMA than to modify it over and over again.

When defining and testing a new database and wish to delete all of the test data for record type n prior to delete schema the following simple VisualPQL program does this (omit the case commands if it is a caseless database):

RETRIEVAL UPDATE
PROCESS CASE
PROCESS REC n
DELETE REC
END PROCESS REC
END PROCESS CASE
END RETRIEVAL

DELETE STANDARD SCHEMA

Deletes the entire standard schema. This modifies any records referencing the standard schema so that they no longer reference the standard. It is strongly advised that the database is rebuilt using export/import or unload/reload as soon as possible if this is done and multiple record definitions are affected.

homecontents start chapter top of pagebottom of pagenext page index

CASE ID

CASE ID varname [(A)|(D)] |
[NO] CASE ID

CASE ID varname establishes the database with a case structure and specifies the name of the variable used on every record as the case identifier.

NO CASE ID establishes the database without a case structure.

Either CASE ID or NO CASE ID is required to set up the database and this command must be used prior to any other definition. Once the case specification and case id have been defined, these cannot be modified.

The case variable may be any data type. Avoid REAL for keys due to the difficulty of specifying exact numbers in floating point.

D specifies descending sort order for cases. If order is not specified, ascending is assumed. When all cases are processed sequentially, they are retrieved in this sequence.

homecontents start chapter top of pagebottom of pagenext page index

COMMON SECURITY

COMMON SECURITY rlevel, wlevel

Specifies the default minimum security levels for all common variables.

Rlevel (read level) and wlevel (write level) are integers between 0 (zero) the lowest, and 30, the highest. If no security levels are defined, level 0, the lowest, is assigned. Further security restrictions for individual common variables can be specified at the record level using the VAR SECURITY command. See READ SECURITY for an explanation of security levels.

Common security levels can be changed. Note, this affects only the security levels for new common variables that are defined or redefined. It does not affect the security levels of currently defined common variables.

homecontents start chapter top of pagebottom of pagenext page index

COMMON VARS

RECORD SCHEMA 0 CIR

Specifies variables in the Common Information Record or CIR. A CIR exists for every case in a case structured database and holds counts plus the case identifier. It can hold Common variables that are typically those that are used repeatedly in retrieving data from the database. These variables can be referenced at any time regardless of the record type being processed. CIR entries can be updated directly when processing a case, or can take the value of the last entry in a given record type.

Note that common vars, except for the case id on a case structured database, cannot be used as key variables in a secondary index in a record as they are not stored as part of a record.

Specify the format here and then, when this variable is referenced on a subsequent record definition, there is no need to respecify formats except input-output columns and any batch data specifications (e.g. RECODE) for that record.

The specification of the CIR is identical to any other record except that the batch data input specification clauses (ACCEPT REC,REJECT REC,COMPUTE,IF and RECODE) are meaningless. Follow the RECORD SCHEMA 0 CIR with a DATA LIST to respecify completely the common vars or use ADD VARS or DELETE VARS to update the common vars.

Use any of the normal record variable definition commands such as VALUE LABELS as required.

The RECORD SCHEMA 0 CIR set of commands follows any STANDARD SCHEMA set of commands and precedes normal record definitions.

(Note: The older format of COMMON VARS is still supported for compatibility with earlier versions of SIR.)

homecontents start chapter top of pagebottom of pagenext page index

DATA FILES

DATA FILES  'filename'
            [FROM (key,...) 'filename']
            [FROM (key,...) 'filename']
            .....
Specifies that the data file for this database is not a standard data file. It may have a different name, be in a different directory or may be split across multiple data files.

Specify the command at the end of the schema definition - it cannot be processed before the type of the Case variable has been specified for a case structured database. If a record type is specified as a FROM key, then that record type must have been defined. When SIR/XS writes a schema, this command follows any secondary indexes.

If the command does not have any FROM clause, it specifies the name and location of the data file. This can be in a different directory from the other database files and named something other than the database name with a .sr3 extension.

The first specification names the original data file that holds all records up to the value specified on the first FROM key. The last specification names the final data file that holds all records from to the value specified on the last FROM key.

On a case structured database, the first key specified is the case id. If any further specification is required, the next key specified is a record number. On a caseless database, the first key specified is a record number. Subsequent keys can be specified up to the maximum number of keys on the record type.

The filenames must either be fully qualified filenames or simple filenames without any directory specification. If the files are not fully qualified then the data file is placed in the same directory as the other database files.

For example:

DATA FILES  'company.s31'
            FROM (500)  'company.s32'
            FROM (1000) 'company.s33'
A DATA FILES command with no other specifications removes any previous data file definition and sets the database to have a standard data file.

homecontents start chapter top of pagebottom of pagenext page index

DATABASE LABEL

DATABASE LABEL 'text'

Specifies a label for the database. This text can be up to 78 characters and is enclosed in quotes. The label can be retrieved in VisualPQL using the RECDOC(0,0) function.

homecontents start chapter top of pagebottom of pagenext page index

DOCUMENT

DOCUMENT text

Specifies that the text following the command is commentary. This text is stored in the dictionary describing the overall database.

The text cannot be partially modified. To alter the text, run the DOCUMENT command with new text. The new document text completely replaces the old.

homecontents start chapter top of pagebottom of pagenext page index

ENCRYPT

ENCRYPT [ON |OFF]

ENCRYPT turns on data encryption for this database. This means that all data records in the database are encrypted on disk and are thus protected against scrutiny from software other than SIR/XS. The encryption method used is a version of the publicly available Blowfish algorithm using a 256 bit key.

All data records are encrypted, however keys in index blocks are held in unencrypted format. Do not use names or other recognisable strings as keys if this data is sensitive and requires protection. Unloads and journals for encrypted databases are themselves encrypted. Text files are all unencrypted. Schemas and procedures are unencrypted.

ENCRYPT OFF turns encryption off for a database. Encryption can be turned on and off without ill effect. Records are written according to the current setting; records are read and recognized as to whether they require decryption.

Passwords and security levels are encrypted on all databases. There are encryption/decryption functions in VisualPQL if users need to encrypt data for themselves but these use a user specified key - the SIR/XS system key is used for database encryption.

homecontents start chapter top of pagebottom of pagenext page index

MAX INPUT COLS

MAX INPUT COLS n

Specifies the length of the largest input line for any record type in the database. N is rounded up to a number evenly divisible by eight. This command is necessary when there is any record type with a batch input format longer than 80. The MAX INPUT COLS can be increased at any time, but cannot be decreased once any record types have been defined.

homecontents start chapter top of pagebottom of pagenext page index

MAX KEY SIZE

MAX KEY SIZE n

Specifies the maximum key size required for any record type in the database. The default is the size of the largest key currently defined for any record type in a database and is calculated automatically.

Only specify an explicit key size if you expect to define a new record type with a larger key than the current largest key after loading data into the database. If MAX KEY SIZE is set to the largest expected key, it avoids having to UNLOAD and RELOAD the database.

The keys for a record are: the Case Id, the record number and the key fields. The current MAX KEY SIZE can be obtained from the database statistics.

The absolute maximum key size possible, whether defined through this command or calculated from the keys specified, is 320 characters.

homecontents start chapter top of pagebottom of pagenext page index

MAX REC COUNT

MAX REC COUNT n

For case structured databases, this specifies the default MAX REC COUNT for individual record definitions. The overall MAX REC COUNT sets the default maximum of a record type for any one case in the database. The number specified for an individual record type may be larger than specified here. The default value is 100.

For caseless databases, use the command N OF RECORDS to specify the maximum number of records that the database can hold.

homecontents start chapter top of pagebottom of pagenext page index

MAX REC TYPES

MAX REC TYPES n

Specifies the maximum number of different record types that can be defined in the database. The default value is 30.

No record type number can exceed the value specified on the MAX REC TYPES command. For example, if MAX REC TYPES is 10, a record type 11 is not allowed, even if there are fewer than ten record types defined.

This number affects the size of the CIR. Space is reserved in the CIR for counts for as many record types as defined in MAX REC TYPES. The case level MAX REC COUNT determines how much space is held for the count of any record type as yet unspecified. For example, if there is a MAX REC TYPES of 30 and a MAX REC COUNT of 100, 30 bytes are reserved for record counts in each CIR. With a MAX REC TYPES of 100 and a MAX REC COUNT of 1,000,000, 400 bytes are reserved.

Changing this number requires a database UNLOAD / RELOAD once data has been loaded.

homecontents start chapter top of pagebottom of pagenext page index

N OF CASES

N OF CASES n

Specifies the maximum number of cases, n, that can be entered in the database. The maximum number of cases is an integrity constraint that limits the number of cases that can be held in the database

The N OF CASES is an absolute value; it cannot be increased without doing an UNLOAD / RELOAD and so specify the value carefully to allow for the maximum number of cases ever wanted in the database.

N OF CASES is multiplied by the RECS PER CASE to establish the total number of records the database can handle. This limit cannot be exceeded and can only be changed with an UNLOAD / RELOAD.

There is no overhead with specifying a large value, the only constraint is that total number of records is a number that can be stored in one integer. This number is 2,147,483,648.

The default N OF CASES is 1000.

Not valid for caseless databases.

homecontents start chapter top of pagebottom of pagenext page index

N OF RECORDS

N OF RECORDS n

Specifies the maximum number of records, n, that can be entered in a caseless database.

The N OF RECORDS is an absolute value; it cannot be exceeded and so specify the value carefully to allow for the maximum number of records ever wanted in the database. This limit can only be changed with an UNLOAD / RELOAD.

There is no overhead with specifying a large value, the only constraint is that total number of records is a number that can be stored in one integer. This number is 2,147,483,648.

The default N OF RECORDS is 1,023,000.

Not valid for case structured databases.

homecontents start chapter top of pagebottom of pagenext page index

READ SECURITY

READ SECURITY (leveln) password ....

Establishes the read security levels and associated passwords. There are 31 levels of security, from 0 (zero), the lowest, to 30, the highest. Repeat the complete specification for each password. Database passwords are a SIR/XS name and must conform to the naming rules. For example
READ SECURITY (1) CLERK (2) SUPER (3) MANAGER

When a user logs in to the database, they specify a Read Security Password. If this matches a password in this list, then they are assigned that security level. If they do not login with a valid read security password, they are assigned level zero.

If security passwords are not defined, anyone who logs on to the database is assigned level 30 (database administrator) read permission.

If a security level 30 password is not defined, anyone who logs on with the highest level password to the database is assigned level 30 read permission.

One level is associated with one password. That is, there may be a password for level 1, a password for level 2, and so on. There cannot be two passwords for the same level. Read access at a particular level grants read access for all lesser levels.

A security level and associated password must be defined before that security level can be specified on a record type or variable.

homecontents start chapter top of pagebottom of pagenext page index

RECS PER CASE

RECS PER CASE n

Specifies an average number of records per case. The default is 1023.

This is used to calculate the total number of records in the database. The product of N OF CASES multiplied by RECS PER CASE forms an upper bound on the total number of records (not including CIRs) that can be stored in the database.

The default N OF CASES is 1000 that means that 1,023,000 is the default total number of records for a database.

This can be updated once records have been entered without an UNLOAD / RELOAD.

This command has no meaning for caseless databases.

homecontents start chapter top of pagebottom of pagenext page index

RECTYPE COLS

RECTYPE COLS n[,m]

When using Batch Data Input utilities, the input file can contain records of different types and an input record type is identified by its record type number. The record type number is an integer and must appear in the same position on all input records regardless of record type.

RECTYPE COLS specifies the columns that contain the record type number. 'n' specifies the start column 'm' specifies the last column. If the record type is in one column, i.e. MAX REC TYPES is less than 10, just specify the start column.

The columns specified must be within the range specified on the MAX INPUT COLS command. The record type number must be on the first line of any multi-line input records. (If records on input files are all of one type, the RECTYPE= clause can be used for the batch data input run and the record type number omitted.)

Make the number of columns large enough to hold the value of the maximum record number. For example, if up to 99 record types are allowed, specify two columns.

The default is columns 79 and 80.

homecontents start chapter top of pagebottom of pagenext page index

SYSTEM SECURITY

SYSTEM SECURITY readpw, writepw

Specifies the passwords associated with the SYSTEM SECURITY LEVEL, if specified. Log on to the database with these passwords to access the system utilities. Currently, only UNLOAD FILE is restricted by the SYSTEM SECURITY LEVEL and therefore this command is not usually specified.

Logging on with a password that is associated with the system security level gives access to all functions.

SYSTEM SECURITY LEVEL

SYSTEM SECURITY LEVEL n

N specifies the security level at which a user can perform a set of DBA-only commands. Log on to the database with the write password associated with this level to access the system utilities. The default system security level is 30.

Currently, only UNLOAD FILE is restricted by the SYSTEM SECURITY LEVEL and therefore this command is not usually specified.

homecontents start chapter top of pagebottom of pagenext page index

TEMP VARS

TEMP VARS varlist

Names temporary variables for use in computations during entry of data with the Batch Data Input utilities. Computations include COMPUTE, RECODE, IF, ACCEPT REC and REJECT REC commands.

Temporary variables are not stored in the database.

homecontents start chapter top of pagebottom of pagenext page index

WRITE SECURITY

WRITE SECURITY (leveln) password ....

Establishes the write security levels and associated passwords. There are 31 levels of security, from 0 (zero), the lowest, to 30, the highest. Repeat the complete specification for each password. Database passwords are a SIR/XS name and must conform to the name format. For example:

WRITE SECURITY (1) CLERK (2) SUPER (3) MANAGER

When a user logs in to the database, they specify a Write Security Password. If this matches a password in this list, then they are assigned that security level. If they do not login with a valid write security password, they are assigned level zero.

If security passwords are not defined, anyone who logs on to the database is assigned level 30 (database administrator) write permission.

If a security level 30 password is not defined, anyone who logs on with the highest level password to the database is assigned level 30 write permission.

One level is associated with one password. That is, there may be a password for level 1, a password for level 2, and so on. There cannot be two passwords for the same level. Write access at a particular level grants write access for all lesser levels.

homecontents start chapter top of pagebottom of pagenext page index

ACCEPT REC IF

ACCEPT REC IF (logical expression)

Only applies to batch data input

Specifies the criteria for accepting records using the Batch Data Input utilities. When the logical expression is TRUE, the record is entered into the database. Multiple ACCEPT REC IF commands can be defined to specify multiple acceptance criteria. If a record passes any one test, it is accepted. If ACCEPT REC IF is specified, all records that do not pass a test are rejected.

ACCEPT REC IF (AGE GE 16 AND LE 65)

Note: ACCEPT RECORD IF cannot be specified in a CIR definition. If an ACCEPT RECORD IF refers to a common variable then it must appear in the record schema where that common variable is referenced rather than at the CIR level.

homecontents start chapter top of pagebottom of pagenext page index

CAT VARS

CAT VARS varname ('value' .... ) varname ('value' .... ) ....

Specifies string variables that are held as categorical integers and defines the set of string values that can be input for the variable.

The values in the value list are each enclosed in single quote marks (') and the list for a variable is enclosed in parentheses. Specifications for multiple variables may be separated with a slash (/) for readability.

Within the database, categorical variables are held as integers that are the position of the string in the value list. For example:

CAT VARS SEX   ('MALE' 'FEMALE' )
         STATE ('AL' 'AK' ....'WY')
Specifies that the variable SEX is categorical. On input 'MALE' is converted to a 1, 'FEMALE' to a 2.

The variable STATE definition illustrates a list of abbreviations of American states. On input 'AL' is converted to a 1, 'AK' to a 2, etc.

When entering data into a CAT VARS, the string value is input, not the code. Note the difference to value labels, where a code is input and a string is associated with the code.

homecontents start chapter top of pagebottom of pagenext page index

CHARACTER

CHARACTER*n varname ....

Specifies variables as character. n may be from 1 to 4094.

Example:

CHARACTER*40 NAME

homecontents start chapter top of pagebottom of pagenext page index

COMPUTE

COMPUTE variable =
expression

Only applies to batch data input

COMPUTE performs arithmetic or string transformations on common, record or temporary variables in Batch Data Input as each record is read. If the computed variable has not been defined, a new database variable is created at the end of the record. It is recommended that computed variables are defined with the appropriate command.

Note: COMPUTE cannot be specified in a CIR definition. If a COMPUTE refers to a common variable then it must appear in the record schema where that common variable is referenced rather than at the CIR level.

Case and Key variables cannot be computed.

homecontents start chapter top of pagebottom of pagenext page index

CONTROL VARS

CONTROL VARS variable ....

Declares a list of variables that are Control variables for the TABULATE procedure. These variables must be numeric and must have either Valid Values or Variable Ranges defined. By default, variables that have Valid Values or Value Labels are Control Variables. All other numeric variables are Observation Variables, that is variables with continuous values.

homecontents start chapter top of pagebottom of pagenext page index

DATA LIST

DATA LIST [(num-lines)]
  [line-no]   varname  [from-column [- to-column]]|[*] [(type)]
  [line-no]   varlist  [from-column [- to-column]]|[*] [(type)]....
Defines the variables and input format for a record. You can either use the DATA LIST or the
VARIABLE LIST / INPUT FORMAT to define the record.

The definition consists of the name, batch data input column locations and data type for each variable. The sequence of the variables determines the order in TO lists and the sequence of the variables wherever they are referenced, regardless of the physical order on the batch data input record.

If the batch data input record requires more than one physical record or line, then the num-lines defines the number of lines which make up the complete record and the line-no defines which line each variable is on. When the input record is only one line, omit the number of lines and line number. The line-no can be omitted for any subsequent variables on the same physical input record.

The from-column determines the start position of the variable.

The to-column specifies the ending position for variables that are longer than one column.

Define the data type of each variable as follows:

A
String.
I
Integer.
Fn
Single precision floating point. On batch data input, n columns at the right of the input field comprise the decimal component of the number. An explicit decimal point on input overrides the format specification.

Dn
Double precision floating point. On batch data input, n columns at the right of the input field comprise the decimal component of the number. An explicit decimal point on input overrides the format specification.

DATE
Date variable in the given date format. The specification consists of the word DATE and the date format, all enclosed in parentheses. See date formats for a complete description.
TIME
Time variable in the given format. The specification consists of the word TIME and the time format, all enclosed in parentheses. See time formats for a complete description.

If the type is omitted, the default is floating point with zero decimal portion.

Example:

DATA LIST  (2)
        1  ID        1 - 4   (I)
           POSITION  6 - 7   (I)
           STARTDAT  8 - 15  (DATE,'MMIDDIYY')
           STARTSAL  17 - 20 (F2)
           DIVISION  21      (I)
        2  NAME      6 - 30  (A)
           GENDER    31      (I)
           MARSTAT   32      (I)
           SSN       33 - 43 (A)
If a varlist is specified, (that is either a list of variable names or a list in the form varname to varname), multiple variables, all of the same size and type, can be defined. The columns specified to contain these variables must be evenly divisible by the number of variables in the list.

homecontents start chapter top of pagebottom of pagenext page index

DATE VARS

DATE VARS varname .... ('date_format') varname .... ('date_format') ....

Specifies that previously defined character variables are date integers with a given date format.

Date formats may be specified directly on the DATA LIST or INPUT FORMAT commands. If using DATE VARS, the variable is specified as a character string on the DATA LIST or INPUT FORMAT commands.

Multiple variables in the same format can be defined with one format specification; additional specifications may be separated by slashes for readability.

See date formats for a complete description of date formats.

homecontents start chapter top of pagebottom of pagenext page index

DOCUMENT

DOCUMENT text

Specifies that the text following the command is commentary. This text is stored within the database and can be printed using the utility LIST SCHEMA.

When DOCUMENT is placed within record definition commands, it becomes part of the definition for that record type.

DOCUMENT text cannot be partially modified. To update the text, run the command with new text. The new document text completely replaces the old.

homecontents start chapter top of pagebottom of pagenext page index

END SCHEMA

END SCHEMA

Specifies the end of the commands for a record set. If it is not specified, the end of the commands, START TASK or END TASK or the start of a new RECORD SCHEMA terminates definition of the record type. Any other commands are treated as record definition commands.

homecontents start chapter top of pagebottom of pagenext page index

IF

IF (logical-condition) varname = expression; ....

Only applies to batch data input

Assigns the result of an expression to a variable if the logical condition is true. Multiple variables can be assigned values on a single condition. Variables referenced must be within this record or must be common vars. If the computed variable has not been previously defined, it is added to the defined database variables. For example:

IF (JOBCODE = 1) REVDATE = TODAY(0) + 365

Note: IF cannot be specified in a CIR definition. If an IF refers to a common variable then it must appear in the record schema where that common variable is referenced rather than at the CIR level.

homecontents start chapter top of pagebottom of pagenext page index

INPUT FORMAT

INPUT FORMAT (format specifications)

INPUT FORMAT is associated with, and immediately follows, the VARIABLE LIST command.

Specify a data type, size and format for each variable on the VARIABLE LIST.

An input file may have multiple lines of data for each database record. Lines in an input record may be any length up to the length specified on MAX INPUT COLS. Specify a slash (/) to indicate the start of the second and subsequent lines of data. The slash can be used to skip one or more lines of an input record.

Separate each format specification by a comma or a space. If the format specifications require more than one line, continue the specification on the next line leaving column one blank.

Specify a single format and a repetition factor for multiple variables with the same format or groups of variables with the same format. To repeat a format, specify the number of times to repeat it, followed by either a single format or a group of formats enclosed in parentheses. For example:

VARIABLE LIST VAR01 TO VAR50
INPUT FORMAT (10I2, 20(I1,I4))

The VARIABLE LIST with the TO format defines 50 integer variables named VAR01, VAR02, ... VAR50.

The first repeating format (10I2) defines the first 10 variables that results in VAR01 to VAR10 as two digit integers.
The repeating group of formats, 20(I1,I4), defines 20 sets of two alternate variables. This results in VAR11, VAR13 and subsequent odd numbered variables as one digit integers (I1) and VAR12, VAR14 and subsequent even numbered variables as four digit integers (I4).

Enclose the whole format specification in parentheses. The individual format specifications are as follows:

Fw.d or Dw.d
A floating point variable. "F" is single precision, "D" is double precision. On batch data input the variable occupies "w" positions on the input file with the rightmost "d" positions as the decimal component. A decimal component must be specified; zero is valid. If Batch Data Input is not used the decimal component has no effect. Specifying a physical decimal point on input overrides any specification. For example:
VARIABLE LIST TEMP SALARY
INPUT FORMAT (F5.3, D8.2 )

Iw
An integer variable occupying "w" positions on batch data input. For example:
VARIABLE LIST STATUS, AGE
INPUT FORMAT ( I1 ,  I2 )

Aw
A character (alphanumeric) variable occupying "w" positions. For example:
VARIABLE LIST NAME ADDRESS
INPUT FORMAT ( A25 , A40 )

nX
A positioning operator for Batch Data Input utilities. It skips "n" columns of an input data record. For example:
VARIABLE LIST NAME ADDRESS
INPUT FORMAT ( A25 , 4X , A40 )

This defines two alphanumeric variables. NAME occupies positions 1 through 25 of the input record. 4X skips the next 4 columns (after NAME). ADDRESS is 40 characters long beginning in position 30.

Tn
A positioning operator for Batch Data Input utilities. It tabs to a specific column "n". The next variable begins in column "n". The "T" specification can be used to move forward or backward over the current input line and can be used to reread a particular field. For example
VARIABLE LIST NAME ADDRESS PHONE AREACODE
INPUT FORMAT (T3,A20,T25,A40,T72,A12,T72,A3)
This defines four string variables using the T operator to locate the beginning of each variable. Note that the variables PHONE and AREACODE both begin in column 72.

DATE 'date format'
Describes an input character variable as a date according to the specified date format. See date formats for a complete description of date formats.
TIME'time format'
Describes an input character variable as a time according to the specified time format. See time formats for a complete description of time formats. For example:
VARIABLE LIST NAME BIRTHDAY BIRTHTIM
FORMAT (A25, DATE 'MM/DD/YYYY', TIME 'HH:MM')

This example defines three variables for a record type. NAME is in the first 25 positions; BIRTHDAY is in the next ten positions and is a date variable; BIRTTIM is a time variable. The first two characters are Hours (24 hour clock), the third character is a separator and the last two are minutes.

homecontents start chapter top of pagebottom of pagenext page index

INTEGER

INTEGER*n varname ....

Specifies variables as integer that can hold positive or negative numbers. n may be 1, 2 or 4 and refers to the internal storage size in bytes. 1 byte holds numbers up to 123; 2 bytes holds numbers up to 32,763; 4 bytes holds numbers up to 2,147,438,643.

If this is subsequently defined as a SCALED VAR, the internal integer must be able to store the significant digits needed for the number. For example if Scale (-2) is specified, the largest number that can be held in I*4 is 21,474,386.43

Example:
INTEGER*4 SALES VAR1 to VAR5

homecontents start chapter top of pagebottom of pagenext page index

KEY FIELDS

KEY FIELD[S] varname [(A|D|I)] ....

Defines the keys for the record. Any record type that has more than one single physical record per case on a case structured database and every record type with more than one single physical record in a caseless database must have a key.

The KEY FIELD command must be before the DATA LIST or VARIABLE LIST.

The key fields must appear in the DATA LIST or VARIABLE LIST

Key field variables cannot be created or modified by COMPUTE, IF or RECODE commands.

The sort specification applies to each variable individually.

Example:

CASE ID         ID
RECORD SCHEMA   3 REVIEW
KEY  FIELDS     POSITION  REVDATE (D)
VARIABLE LIST   ID POSITION REVDATE          RATING  NEWSAL IDSUPER
INPUT FORMAT   (I4 I2       DATE('MMIDDIYY') I2      F8.2   I4)

homecontents start chapter top of pagebottom of pagenext page index

MAX REC COUNT

MAX REC COUNT n

For a case structured database this command specifies the maximum occurrences of a record type for any one case in the database. If a value is not specified for a record type, the MAX REC COUNT from the database specification is used. The number specified for a record type may be larger or smaller than specified at the database level. The default value is 100.

Counts are kept for each record type in a case in the CIR for that case. They are stored as 1, 2, or 4 byte integers depending on the count specified. A count of less than 124 takes 1 byte, less than 32,763 takes 2, and larger numbers take 4. If MAX REC COUNT is modified after data for that record type has been loaded, and the new number takes the same size integer, restructuring is unnecessary. If a larger size integer is needed, the database must be restructured.

For caseless databases, MAX REC COUNT specifies the maximum number of records of this type that the database can hold. The default value is 1,023,000. This limit cannot be exceeded but can be changed without a database restructure. There is no overhead with specifying a large value, the only constraint is that total number of records is a number that can be stored in one integer. The total number of records allowed is 2,147,483,648.

homecontents start chapter top of pagebottom of pagenext page index

MISSING VALUES

MISSING VALUES varname (value1 [value2 [,value3]] ) ....
               varlist (value1 [,value2 [,value3]] ) ....
Specifies up to three values that are missing values for the variable(s). Missing values are excluded from
statistical procedures and functions. When the variable is input or modified, and one of the specified values is input, the appropriate missing value is set.

The value can be a numeric constant, a string constant, or the keyword BLANK. If BLANK is specified as a missing value for a numeric variable, then a blank field on input results in a missing value, otherwise a blank numeric field is translated to zero.

Any variable can be missing and has a system missing value. When a record is written to the database, a variable is assigned the system missing value when it cannot be assigned a legal value or a specified missing value. This happens when:

Specify any missing values for string, categorical, date and time variables as strings. If the variable is longer than the missing value, then the variable is set to missing values if the leftmost characters match the specified missing value.

If a string is read into a date or time, that string is first checked to see if it is a missing value string for the target variable. If it is then a missing value is stored. Any string can be defined as missing - it need not be a valid date. If the missing value is a valid date string then assigning that string to the variable naturally results in a missing being stored. However assigning the numeric date value corresponding to the missing string stores a valid date.

Specify any missing values for scaled variables as the unscaled value with the decimal point specified where necessary.

Example:

MISSING VALUES ID POSITION DIVISION (BLANK)
               STARTDAT ('01/01/01')

homecontents start chapter top of pagebottom of pagenext page index

OBSERVATION VARS

OBSERVATION VARS varname ....

Specifies variables that the TABULATE procedure uses as observation variables. An observation variable is one that is aggregated rather than treated as a control. By default, variables that have VALID VALUES or VALUE LABELS are Control Variables. OBSERVATION VARS makes these observation variables.

homecontents start chapter top of pagebottom of pagenext page index

REAL

REAL*4 varname ....
REAL*8 varname ....

Specifies variables as real. n may be 4 or 8.

Example:
REAL*8 SALARY

homecontents start chapter top of pagebottom of pagenext page index

REC SECURITY

REC SECURITY rlevel , wlevel

Defines the default minimum security levels required for reading (rlevel), or writing (wlevel), any variable in the record. The read and write levels are integers between 0 (zero), the lowest and 30, the highest.

This command sets the minimum VAR SECURITY for each variable in the record type. Individual variables within a record type can be assigned higher security levels using the VAR SECURITY command.

The default is 0 level security.

Example:

REC SECURITY 10,30

The variables in this record type can be read by anyone logged in with a read security password that has level 10 security or higher. Write access is restricted to personnel logged in with a write security password that has level 30 security.

homecontents start chapter top of pagebottom of pagenext page index

RECODE

RECODE variable specification (recode specification)

Only applies to batch data input

RECODE changes the values of a string or numeric variable into new values. A variable can be recoded into itself or the content of the original variable can be left unchanged and a value assigned to another variable.

The RECODE has two parts the Variable specification and the Recode specification.

Variable Specification

The variable specification takes four forms:

Recode Specification

A recode specification follows the variable specification and consists of a number of clauses, one per new value to assign. Enclose each clause in parentheses. These can take a number of forms:

Note the sequence of the variables in the variable specification and the sequence of values in the recode specification:

Recode Examples:

RECODE A (1,3,5,7,9=1)(2,4,6,8=2)
This sets A to 1 if it is odd, 2 if it is even, and leaves zero and missing values as is.

RECODE B = A (1,3,5,7,9=1)(2,4,6,8=2)
This sets B to 1 if A is odd, 2 if A is even and zero if A is zero. If A is missing, B is set to the value of A (whether this is a missing value for B or not). A is unchanged.

RECODE B = A (1,3,5,7,9='O')(2,4,6,8='E')
This sets B (a string variable) to 'O' for odd values of A, 'E' for even values of A and to the value of A if A is missing or has any other values.

RECODE STATUS = AGE (LO THRU 18 = 1) (19 THRU 21 = 2)
                    (22 THRU 65 = 3) (66 THRU HI =4)
This sets STATUS depending on the AGE of the subject. STATUS is 1 for ages 18 or under, 2 for ages 19 thru 21, 3 for 22 to 65 and 4 for over 65.

RECODE STATUS1 to STATUS10 =  TEST1 to TEST10(1 THRU 49=1)
                                             (50 thru 99=2)
This sets up ten status fields depending on the result of 10 tests.

Note: RECODE cannot be specified in a CIR definition. If a RECODE refers to a common variable then it must appear in the record schema where that common variable is referenced rather than at the CIR level.

homecontents start chapter top of pagebottom of pagenext page index

RECORD SCHEMA

RECORD SCHEMA rectype [,name ['label']]
       [LOCK]
       [NOOLD]
       [NONEW]
This is a DBA only command.

Begins the set of commands to define a database record. This defines the name and number of the record and is a required command to define a record type. Name is optional for existing record types; if specified and different to the existing name, the record name is changed. The label is optional but if specified then the name is required. Specify up to 78 characters enclosed in quotes. e.g.

RECORD SCHEMA 3 OCCUP 'Position Details'

LOCK

Specifies that the record type can be locked if the record redefinition requires it. Schema modifications are not done if the LOCK keyword is omitted and a lock condition occurs. If the record type is locked, an UNLOAD / RELOAD is required. Lock conditions occur when:

  • the list of key fields is changed
  • any of the key variables are modified
  • a record is defined that is larger than the current data block
  • a set of keys is defined that is larger than the current key size
If the LOCK parameter is omitted and changes are specified that would cause a locked record type, a warning is issued and the schema changes do not take place. This means that a restructure is only done when expected.

It is good practice not to specify lock on the record schema statements except when the change is expected to lock the record and you are prepared to do a restructure.

A restructure may be required when modifying the key structure definition of a record type that already has data loaded into it.

NOOLD

Specifies that existing variables cannot be modified.

NONEW

Specifies that no new variables can be created.

homecontents start chapter top of pagebottom of pagenext page index

REJECT REC IF

REJECT REC IF (logical condition)

Only applies to batch data input

Defines criteria for rejection of records during Batch Data Input. When the condition is true, the record is rejected and not entered into the database. Multiple REJECT REC IF commands can be specified.

The alternative method of specifying consistency criteria is with ACCEPT REC IF.

The record must pass all specified tests before being added to the database.

Note: REJECT RECORD IF cannot be specified in a CIR definition. If a REJECT RECORD IF refers to a common variable then it must appear in the record schema where that common variable is referenced rather than at the CIR level.

homecontents start chapter top of pagebottom of pagenext page index

SCALED VARS

SCALED VARS varname (power) ....

Specifies that the previously defined integer variables are scaled. SCALED VARS are stored in the database as integers. This saves space and can be more accurate for fixed format numbers since it avoids the inherent inaccuracies of floating point representation.

POWER is a positive or negative number representing the power of ten used to scale the values.

The full, unscaled number, including the decimal point where necessary, is specified whenever the number is input by the user.

The scaled number is expected on batch data input.

Examples:

DATA LIST    VAR1      1-3 (I)
             VAR2      4-11 (I)
SCALED VARS  VAR1 (6)
             VAR2 (-2)
This declares two variables as scaled variables. When used in a program:
COMPUTE VAR2 = 345.67   |(34567 is stored)
COMPUTE VAR1 = 1000000  |(1 is stored)
COMPUTE VAR3 = VAR1 * 3
WRITE          VAR3     |(3000000 is printed)
If a batch data input record has 123 in positions 1 to 3 and 00001234 in positions 4 to 11, then VAR1 equates to 123,000,000 and VAR2 to 12.34.

homecontents start chapter top of pagebottom of pagenext page index

STANDARD SCHEMA

The schema command STANDARD SCHEMA is similar to a RECORD SCHEMA command in that it signifies the start of a set of variable definitions. The set is ended with an END SCHEMA command. Variables are defined using a DATA LIST command together with any of the normal variable definition commands such as MISSING VALUES, VALUE LABELS or VAR RANGES. e.g.
STANDARD SCHEMA
DATA LIST
                POSITION                         *             (I1)
                SALARY                           *             (I2)
                SALDATE                          *             (DATE'MMIDDIYY')
VAR RANGES      POSITION                         (1 18)
                SALARY                           (600 9000)
VAR SECURITY    SALARY                           (30,30)
MISSING VALUES  POSITION                         TO
                SALDATE                          (BLANK)
VALUE LABELS    POSITION                         (1)'Clerk'
                                                 (2)'Secretary'
                                                 .............
VAR LABEL       POSITION                         'Position'
                SALARY                           'Salary'
                SALDATE                          'Date Salary Set'
END SCHEMA
Once a variable has been defined in the standard schema it can be referenced in any normal record definition with the
STANDARD VARS command. The benefit of this is that coding does not have to be repeated for the variable when it occurs in multiple records. Further, if the standard definition details are updated (such as value labels), the change is reflected in all records referencing the standard.
Note that the extended batch data input processing definitions of ACCEPT REC,REJECT REC,COMPUTE,IF and RECODE are not specific to a variable and thus cannot be specified as standard and copied in.

homecontents start chapter top of pagebottom of pagenext page index

STANDARD VARS

STANDARD VARS varname [AS stdvarname] The STANDARD VARS command names a variable or list of variables that have previously been defined as part of this record (on the DATA LIST). This includes all the standard definitions for the variable as part of this record without the need to respecify these definitions. If these definitions are changed for the standard variable, all derived record definitions are updated.

Certain definitions can be supplied locally. The VAR SECURITY, VAR LABEL and VAR DOC can be specific to the variable in this record type and override any specified as standard. All other definitions such as MISSING VALUES, VALUE LABELS etc, are taken from the standard definition.

Optionally the record variable can have one name and can refer to a standard variable with the AS keyword. e.g.

RECORD SCHEMA 1 EMPLOYEE
DATA LIST
              ID                                   1 -     4 (I2)
              NAME                                 6 -    30 (A25)
              GENDER                              31         (I1)
              MARSTAT                             32         (I1)
              SSN                                 33 -    43 (A11)
              BIRTHDAY                            44 -    51 (DATE'MMIDDIYY')
              EDUC                                52         (I1)
              NDEPENDS                            53 -    54 (I1)
              CURRPOS                             55 -    56 (I1)

STANDARD VARS CURRPOS AS POSITION
If an existing variable is modified to be a standard variable, any local definitions are overwritten. Submitting local definitions for components of the schema that are derived from the standard is treated as an error. To change a variable from a standard definition to be a normally defined variable is not possible; delete the standard variable and add a new variable (with the same name if necessary).

homecontents start chapter top of pagebottom of pagenext page index

TIME VARS

TIME VARS varname .... (time format) varname .... (time format) ....

Declares string variables as times. See time formats for a complete description of time formats.

Example:

TIME VARS   ELAPSED       ('HH:MM')
            MIN1 to MIN10 ('MM:SS')

homecontents start chapter top of pagebottom of pagenext page index

VALID VALUES

VALID VALUES varname  (value, .... )
             varlist  (value, .... ) ....
Defines the set of valid values for a variable. Valid values can only be specified for numeric variables. (Use the
CAT VARS command to create a list of valid values for string variables.)

The specified valid values are checked whenever a variable is input or modified.

If a value is assigned to the variable that is not in the VALID VALUES list or in the MISSING VALUES list, the value is not stored and the variable is set to undefined.

The varlist may be a specific list of variables or may be in the format VARA to VARX that specifies all the numeric variables between the named variables (listed in sequential order) in the record schema.

Example:

VALID VALUES JOBCODE          (1,3,4,5)
             TEST1 to TEST9   (1,2,3,4,5,9)
             TYPE KIND REASON (1,2,3,9)

homecontents start chapter top of pagebottom of pagenext page index

VALUE LABELS

VALUE LABELS  varname1  (value1) 'label1'
                        (value2) 'label2' ....
              varlist   (value1) 'label1' ....  ....
Specifies labels for particular values of a variable.

Enclose each value for a variable in parentheses. The value may be numeric or character depending on the variable type. Enclose character strings in quotes. The keywords UNDEFINED and BLANK can be used as a value to assign labels to the system missing value (undefined) or blank missing values.

The label is up to 78 characters long. It is good practice to enclose the label in quotes as this is a character string. If the label contains slashes or brackets then the label must be enclosed in quotes.

The varlist may be a specific list of variables or may be in the format VARA to VARX that specifies all the numeric variables between the named variables (listed in sequential order) in the record schema.

Example:

VALUE LABELS  GENDER         (1) 'Male'
                             (2) 'Female'
              MARRIED        ('Y') 'Married'
                             ('N') 'Not Married'
              TEST1 to TEST9 (1) 'Passed'
                             (2) 'Failed'

homecontents start chapter top of pagebottom of pagenext page index

VARIABLE LIST

VARIABLE LIST varname1 varname2 ....

Names the variables on the input record for a given record type. Together with the INPUT FORMAT, this describes the input record. There is a one-to-one correspondence between the variables on the VARIABLE LIST and the format specifications on the INPUT FORMAT.

The sequence of the variables on the VARIABLE LIST determines the order in TO lists and the sequence of the variables wherever they are referenced, regardless of the physical order on the batch data input record.

Separate variable names by spaces or commas. To continue the list on multiple lines, leave column one blank on each subsequent line.

Example:

VARIABLE LIST ID JOBCODE REVDATE SALARY INPUT FORMAT (I4,I2,DATE'MM/DD/YYYY',I4)

homecontents start chapter top of pagebottom of pagenext page index

VAR DOC

VAR DOC varname text
 text line 2
 text line .....
Specifies documentation for a single variable.

The documentation can extend over multiple lines, each up to 254 characters. There are no restrictions on characters and the format of lines is maintained. Each continuation line must leave the first column blank. Note that because documentation can contain any characters, the command must be specified separately for each variable - it cannot be continued for multiple variables.

Example:

VAR DOC  ID    This is the main identification for participants in the study.
 The code is in two parts separated by slash '/' - the first part identifies the institution, the second the individual.
VAR DOC  DOB   ...........................
 .........................................
VAR DOC  VAR1  ...........................

homecontents start chapter top of pagebottom of pagenext page index

VAR LABEL

VAR LABEL
       varname1 'label'
       varname2 'label' ....
Specifies a label for variables. The label is a string up to 78 characters. It is good practice to enclose the string in quotes. This is used by SIR/XS instead of the variable name wherever it is appropriate, for example, on report headings, screen layouts, etc.

Example:

VAR LABEL   ID        'Identification Number'
            POSITION  'Position Level'
            STARTDAT  'Starting date'
            STARTSAL  'Starting salary'
            DIVISION  'Division'
In this example, "Starting date" is printed or displayed instead of "STARTDAT" and "Starting salary" instead of "STARTSAL".

homecontents start chapter top of pagebottom of pagenext page index

VAR RANGES

VAR RANGES varname (min,max) ....

Specifies the range of values for a variable. The ranges defined for a variable are checked whenever that variable is input or modified. Input values outside the specified range are set to undefined.

Example:

VAR RANGES  POSITION (1 18)
            STARTSAL (10000 90000)
            DIVISION (1 3)
            STARTDAT ('01/01/00', '01/01/06')
If both VAR RANGES and
VALID VALUES are specified, both specifications apply. Only values consistent with both specifications are allowed into the database. Normally, specify only one of these.

homecontents start chapter top of pagebottom of pagenext page index

VAR SECURITY

VAR SECURITY varname (rlevel, wlevel) ....

Defines security level values for reading and writing individual variables.

Rlevel and wlevel are integers between 0 (zero) the lowest, to 30 the highest. The VAR SECURITY assigned to an individual variable must be higher than the security level assigned to the record through REC SECURITY. (Assigning a lower level is possible but has no effect.)

Example:

RECORD SCHEMA ....
REC SECURITY 0 5
  .
VAR SECURITY SALARY (6 10)
In this example, anyone can read the data in this record type, but only users logged in with passwords at level 5 or above for write security can write data. The variable SALARY is made more secure, since it requires that read access is at level 6 or above and write security at least at level 10.

homecontents start chapter top of pagebottom of pagenext page index

CREATE DBINDEX

CREATE [UNIQUE] DBINDEX index_name
        ON [database.]recname
        (var_name [ASC|DESC] [UPPER] [, ...] )
CREATE DBINDEX creates the index structure. If the command is part of a schema definition, it must follow the complete definition for the record type referenced. There may be multiple indexes for a given record type.

If the record type already contains data, the index is automatically built from the values of any existing records. As records are added, deleted or modified through any of the SIR/XS modules including VisualPQL, batch data input, Forms and SQL, the index is automatically maintained. VisualPQL and PQLForms are the only modules that process database records using secondary indexes.

Indexes are maintained across cases in a case-structured database and, if a record is retrieved using a secondary index, the appropriate case is automatically found. Index variables can be any record variable plus the case id. Common vars cannot be used in an index.

Indexes are rebuilt whenever the database is recovered i.e. from an Import or a Reload. The backups contain only the index definition not the index data.

UNIQUE
Specifies the index can only contain unique values. If data already exists and a non-unique value is found, the index cannot be built. If an attempt is made to add or modify a data record such that a non-unique value would result, the update is rejected.

index_name
The index name must follow the rules for SIR/XS names and must be unique within the database.

ON recname
Specify the record name or number, qualified by a database name if this is not the default database. The database must be connected.

var_name
Specify the name(s) of the variable(s) used for this index. These must be variables in the named record (not common vars except for the case id).

Specify the keyword DESC to maintain the index in descending sequence of the variable.

Specify the keyword UPPER to use an uppercase representation of a character variable in the index.

DROP DBINDEX

DROP DBINDEX index_name ON [database.]recname | ALL
DROP DBINDEX deletes either a specific index or all indexes for a database.

homecontents start chapter top of pagebottom of pagenext page index

SIR SCHEMA LIST

SIR SCHEMA LIST
    [FILENAME= 'fileid']
    [DETAILED|LABELS|REGULAR]
    [LONG|SHORT]
    [STRUCTURED]
    [CIR]
    [RECTYPES={recname|recnum} [(variable list)]... ]
Produces a listing of the current data definitions. The FILENAME specifies the output file. If this is omitted, the output is displayed in the scrolled output window.

By default, all record types in the database are listed. By default, all variables in the record type are listed. Each variable has a label that describes the variable and its position within the record. Positions are shown as Cnnn, Rnnn, or Tnnn where C stands for common variable, R for record variable and T for temporary variable. The nnn denotes the position of the variable within the record.

The exact format of the report depends on the options specified:

Examples: To list the name and labels of all the variables in record type 1 and the specified variables in record 3.

SIR SCHEMA LIST LABELS
                RECTYPES = 1 , 3 (POSITION REVDATE RATING)
To list all the variables in all record types without value labels.
SIR SCHEMA LIST

Example Output:

1.1      LIST SCHEMA LONG     07/09/05  10:05:57
        *** RECORD 1 (EMPLOYEE) DEFINITION ***
        Record Type 1 contains demographic information.
        There is one record per employee.  The record contains
        current position level and salary and the date
        on which the salary was last changed.

MAXIMUM NUMBER OF RECORDS/CASE        1
NUMBER OF THIS TYPE IN FILE           20
LINES IN EACH INPUT RECORD            1
ENTRY USE COUNT                       1
CASE IDENTIFIER:                      ID       (A)

        *** INPUT VARIABLE DEFINITIONS ***
C1.     ID,       Identification Number
        INPUT  ON LINE:  1
               COLUMNS:  1 - 4
                FORMAT:  I4
        DATA TYPE:       I*2
        MISSING VALUE:   (BLANK)

R1.     NAME,     Name
        INPUT  ON LINE:  1
               COLUMNS:  6 - 30
                FORMAT:  A25
        DATA TYPE:       A*27
        MISSING VALUE:   (BLANK)

R2.     GENDER,   Gender
        INPUT  ON LINE:  1
                COLUMN:  31
                FORMAT:  I1
        DATA TYPE:       I*1
        RANGE:           1/2
        MISSING VALUE:   (BLANK)
        VALUE LABELS:    (1) Male
                         (2) Female

homecontents start chapter top of pagebottom of pagenext page index

WRITE SCHEMA

WRITE SCHEMA
    [FILENAME= fileid]
    [RECTYPES= rectype list]
    [CIR]
    [COMMON]
    [DBDEF]
    [FORMS]
         [BOOLEANS]
         [COMPUTES]
    [LOCK]
    [MASKPW]
    [NOCOLS]
    [NOINDEX]
    [NOMAXKEY]
    [NOTO]
    [NOTXS]
    [PASSWORD]
    [PQLFORM]
         [NOUPDATE]
         [SUBROUTINE]
    [SECURITY]
    [STANDARD]
    [VARLIST]
    [VARSEQ]



Writes a text file containing the schema definition. This might be used to recreate the database without data or procedures or, if it is the schema for a single record type, as the starting point to update that record definition. If mass changes are required to a database definition, it is sometimes easier to create a schema file and use a text editor to do global changes rather than modifying individual records through menus.

With the PQLFORMS parameter, this utility creates a default PQLForm.

With the FORMS parameter, this utility creates a default old Form.

If no record types are specified and the CIR, STANDARD and DEFDB keywords are not used then the database definition and all record definitions are written (excluding passwords).

FILENAME

Specifies the output file. If this is omitted, the output is displayed in the scrolled output window.

RECTYPES

Specifies the record types selected to generate a record or form definition.

CIR

Specifies that a record definition is written for the CIR. This is done anyway when no RECTYPE list, STANDARD or DEFDB is used, so this is only needed if any of these are also specified. If just CIR is specified, then just the CIR is written.

COMMON

The record definition for the CIR includes definitions for all the common variables and so these do not need to be repeated on subsequent record types that include a common variable. Specify COMMON if commands are to be produced for each common variable on every record where it occurs.

DBDEF

Writes out the database creation commands when otherwise they wouldn't be written. If this keyword is used alone it suppresses all record definition output.

FORMS

Creates a default old style form. Unless otherwise specified, the CIR (Common Information Record) is not included in the form definition. Specify the keyword BOOLEANS to use any ACCEPT REC IF or REJECT REC IF specifications to generate appropriate commands in the output form. Specify the keyword COMPUTES to use any COMPUTE and IF commands to generate appropriate commands in the output form.

LOCK

Specifies that the /LOCK keyword is included on all RECORD SCHEMA commands in the generated schema. This means that if the schema text is modified and run then the database records could become locked and require unload and reload. Without the LOCK keyword these major changes would not be successful.

MASKPW

Specifies that an asterisk (*) is written instead of passwords.

NOCOLS
Suppresses the writing of column numbers in the DATA LIST.

NOINDEX
Suppresses the writing of secondary index definitions after the schema.

NOMAXKEY
Suppresses the writing of a specific MAX KEY command to the output file. Specify this option whenever schema modifications are being made to allow the system to recalculate the maximum key size unless a larger key is required for future expansion.

NOTO
Where contiguous record variables share the same specification, a shorthand specification is written using the keyword TO. e.g.
MISSING VALUES  NAME
            TO  NDEPENDS                         (BLANK)
Specify the NOTO keyword to suppress this shorthand and to list all variables individually.

NOTXS

Specifies that the schema is as compatible as possible for use by earlier versions of SIR. New features such as STANDARD VARS and RECORD SCHEMA 0 are not written and slashes are generated as separators.

PASSWORD

Specifies that the database password is written to the file.

PQLForms

Creates a default PQLForm. Unless otherwise specified, the CIR (Common Information Record) is not included in the PQLForm definition. Specify the keyword NOUPDATE for a read-only PQLForm. Specify the keyword SUBROUTINE for a PQLForm that compiles and saves as a sub-routine.

SECURITY

Specifies that the database security level passwords are written to the file.

STANDARD

Specifies that a record definition is written for the STANDARD Schema. This is done anyway when no RECTYPE list, CIR or DEFDB is used, so this is only needed if any of these are also specified. If just STANDARD is specified, then just the STANDARD schema is written.

VARLIST
The standard style of schema output is to write variable names and input definitions as a DATA LIST. VARLIST specifies that variable names are written as a VARIABLE LIST command followed by input definitions as an INPUT FORMAT command. e.g.
VARIABLE LIST ID NAME GENDER MARSTAT ...
INPUT FORMAT (I4,T6,A25,I1,I1,...
VARSEQ
The standard style of schema output is to write each definition command once and to list variables within the command. The VARSEQ keyword specifies that the output is in variable sequence and that all commands that apply to a single variable are grouped together. e.g.
VAR LABEL       NAME                             'Name'
MISSING VALUES  NAME                             (BLANK)

VAR LABEL       GENDER                           'Gender'
VAR RANGES      GENDER                           (1 2)
MISSING VALUES  GENDER                           (BLANK)
VALUE LABELS    GENDER                           (1)'Male'
                                                 (2)'Female'

VAR LABEL       MARSTAT                          'Marital status'
VAR RANGES      MARSTAT                          (1 2)
MISSING VALUES  MARSTAT                          (BLANK)
VALUE LABELS    MARSTAT                          (1)'Married'
                                                 (2)'Not married'

Resubmitting Whole Schema

If you specify a DATA LIST for a record schema that is already defined, then all existing definitions are ignored and the record is defined according to the new schema. Otherwise, RECORD SCHEMA modifies the definition. Modifications include labels and codes. You can add new variables and delete existing variables. You can modify a variable's data type, external format or position for batch data input.

When modifying data types for variables that already have data stored in the database, the data must be reformatted. Be careful if modifying a variable's data type. The following table indicates the result of changing data types.

T - Transfer value
C - Convert to new type
X - Convert to numeric if string is a valid number
U - Convert to undefined
To
StringCat

Var

DateTimeIntegerReal
FromString TCCCXX
CatvarCTUUTC
DateCUTUTC
TimeCUUTTC
IntegerCTTTTC
RealCCCCCT

When transferring values, ranges, missing values, valid values and all schema definitions are checked and appropriately handled. Strings are truncated if they cannot fit in the new definition. Floating point numbers are truncated if they are converted to unscaled integers.

homecontents start chapter top of pagebottom of pagenext page index