# Transformations

## Introduction

Transformation is the process of modifying the data (for example, dividing all of the data values in a field by 10) or deriving new data for analysis (for example, summing the data in two fields). Sometimes it will be easier to use a spreadsheet to calculate derived variables than to modify variables using ASReml transformations.

Note that in ASReml
• alpha and integer fields are converted to numbers before transformations are applied,
• transformations may be applied to any data field since all data fields are stored as real numbers, but it may not be sensible to change factor level codes,
• all fields in a record are read before transformations are performed,
• transformations are performed in the order of appearance.
• ## Syntax

Transformations have one of six forms, namely
 Forms Function Example !o to perform an operation on the current field !ABS to take absolute values, !o v to perform an operation involving an argument on the current field, !+3 to add 3 to all elements in the field, !oVn to perform an operation o on the current field using the data in another field ( v ) !-V2 to subtract field 2 from the current field. !Vt to change the field modified by subsequent transformations, !V12 changes focus to variable 12 !Vt=c to change all of the data in a target field to a given value, !V12=1. !Vt=Vn copy field n to field t; special case is !Vt=V0 instructing ASReml to put the record number into the target !V12=V3
In these definitions, V is the literal captital V character. The combination Vn can be replaced by the LABEL of the field if the field is already labelled.

### Rules

• ! flags the presence of the transformation
• o is the operator or function name,
• v is the argument required by the transformation,
• V is a literal character and is followed by the number t (target) or n (argument) of the data field; the data field is used or modified depending on the context,
• Vt or Vn may be replaced by the name of the field if the field is already named.
• in the first three forms the operation is performed on
• the current field; this will be the field associated with the label unless this field has been reset by specifying a new target in a preceding transformation,
• the fourth form changes the focus
• for subsequent transformations to the field target,
• in the last two forms the operation
• is performed on the target field which is modified as a consequence, for example, to create a copy of field 11, which is an existing data field, we would use
``` !V22=V11
```
which copies field 11 into field 22; if field 22 does not exist in the data it is created; note that subsequent transformations on the line will also apply to the target ,
• ASReml expects to read values for each variable from the data file unless the variable
• and all subsequent ones are created using != . The number of variables read can be explicitly set using the !READ qualifier

### Transformation functions

• arithmetic operators = + - * / ^ == <= >= <>
• Algebraic operators ABS ARCSIN SIN COS EXP MIN MAX MOD
• genetic marker operators MMAP DOM
• date operators Jddm Jmmd Jyyd Jddy
• Drop records D
• missing value operators M NA
• substitution operators SEQ SET SUB REPLACE RESCALE
• distribution operators SEED NORMAL UNIFORM