EpiData Analysis: Guide de référence des commandes et des fonctions
Document version 0.42


Lire information de version pour la liste des modifications et adaptations en function des numéros de version .

Les commandes sont regroupées par fonction.

[ ... ] indique un (des) paramètre(s) optionnel(s)
{ a|b|... } indique un choix de paramètres
les fields représentent des valeurs stockées dans un fichier de données et lues par une commande read
les variables sont des valeurs en mémoire lues d'un champ ou générées par un calcul

Les groupes de commandes suivants sont accessibles:
 

La plupart des commences obéissent aux mêmes règles de syntaxe qu'Epi Info version 6. Cliquer ici pour connaître les différences avec Epi6

Commandes utilisables dans EpiData Analysis

Top Read & Start
read read [nomdefichier[.{rec|dbf|csv}]] [/close]
Lit un fichier de données -  /close (optionnel) vide la mémoire des fichiers précédement ouverts.
- Sans paramètre, la commande read ouvre une fenêtre de dialogue pour le choix du fichier
 L'activation des enregistrements marqués 'Effacé' est contrôlable par la commande: set read deleted=ON[OFF]
Note: Le repertoire de travail par défaut change lorsque vous utilisez la fenêtre de choix de fichier, mais ne change pas si saisissez le nom du fichier
append append [nomfichier[.{rec|dbf|csv}]]
 ajoute à la suite du fichier les enregistrements d'un autre fichier de structure identique
- seuls les champs de meme nom que ceux déjà en mémoire seront lus
Les variables du premier fichier qui n'apparaissent pas dans le fichier annexé sont mises à 'manquant' dans les enregistrements du fichier annexé.
select if
select
select [expression_logique]
 permet de ne travailler qu'avec une sélection de fiches.
- plusieurs commandes 'select' consécutives s'ajoutent (and)
- sans paramètres, annule l'ensemble des selections actives
Attention: La prudence s'impose lors de la sélection sur une variable décimale (ex. v1 > 3.1
Contrôlez la sélection avec la commande "browse ...." Assurez vous en particulier que le programme gère les données manquantes comme vous le souhaitez.
Note: Les variables "chaines" sont comparée sans tenir compte des espaces de fin.
Pour ne pas tenir compte des espaces placés en début de chaine, utilisez la fonction trim :
ex: select trim(User) = "Jorge" or select trim(upper(User)) = "JORGE"
temporary
select
faite suivre une commande de la fonction si:  if (expression_logique)
La commande n'utilisera que les fiches pour lesquelles l'expression logique est vraie.
pour utiliser des expressions logiques complexes, utiliser des parenthèses
- note :il est possible d'interagir avec l'utilisateur . exemple:  count if sexe=?Write  value 1 2
Vérifiez systématiquement la cohérence des résultats en ce qui concerne la façon dont les données manquantes sont traitées, ainsi que les sélections sur des variables à plusieurs décimales. 
Note: Les calculs sur des variables alphanumériques ne tiennent pas compte des espaces éventuels à droite.
ex: "Lion " et "Lion" sont identiques, mais sont différents de " Lion".
run run [nomfichier[.pgm]]
Execute les commandes continues dans un fichier de programme (nomfichier.pgm)
RUN seul ouvre la fenêtre de choix de fichier
Runtest runtest [nomfichier.pgm] [folder]
Exécute tous les fichiers pgm dans le repertoire spécifié et ses sous repertoires éventuels et affiche les tables de résumé $assert et $assert_error
$assert et $assert_error sont réinitialisées au démarrage de runtest.
Peut être utilise pour documenter la precision ou la validation de procédures.
Cette commande est utilisée pour vérifier et documenter le fonctionnement correct d'EpiData Analysis.
Top Basic analysis
count if
count
count
count if [expression_logique]
Compte les enregistrements.
count if (expression_logique) affichera le nombre d'enregistrements correspondant à ceux pour lesquels la declaration logique est VRAIE.
Count est stocké dans une variable résultat $count .
Utilisez la commande var results pour en afficher les noms et la structure.
Note: if doit être utilise avec précautions avec les variables décimales.
count if 10*var1 >= 31 // permet de compter les enregistrements pour lesquels var1 est >= 3.1 en éliminant les problème possibles liés à la variable décimale.
Note: l'utilisateur est responsable de la vérification de la cohérence de déclarations 'if' complexes.
describe
des
describe [variable1 ] [variable2 ...] [/Quiet] [/N /Nomissing]
Fourni des statistiques descriptive de distribution pour chaque champ numérique. describe décrira toutes les variables.
/N ou /NoMissing: seules les valeurs renseignées sont utilisées (manquants exclus).
- les résultats peuvent être sauvés sous forme d'un fichier de données avec
aggregate
Les estimations sont sauvées comme variables de résultat.
var results en affichera les noms et la structure.
Si
aucun nom de variable n'est spécifié, toutes les variables sont utilisées.
   (describe /N ne marche pas; pour voir toutes les variables utilisez : describe * /N)
Specifier le design:
set table design stat=line[box][filled][...]
Describe requière plus d'une observation pour une variable donnée  
Note : les percentiles sont pondérés pour tenir compte de l'écart entre les observations.
Ref: Bland M.Introduction to Medical Statistics, Oxford, 1995. Second Ed. p 55
means
mea
means variable1 [variable2 ...] [/quiet /q]
Statistiques descriptive élémentaires pour la variable numérique variable1, stratifies sur la variable2
- si plus d'un champ est spécifié, means fera également une analyse de variance, considérant toutes les autres variables spécifies comme des facteurs.
set statistics=on[off] pour les tests de Bartlett
Les résultats sont stockées dans des variables résultat.
Utilisez var results pour en afficher les noms et la structure.
Spécifier
le design:
set table design stat=line[box][filled][...]
Spécifier le design table anova:
set table design summary=line[box][filled][...]
Note: Les intervalles de confiance sont donnés en utilisant une T-distribution avec N-1 degrés de liberté.
freq
fre
freq variable1 [variable2 ...] [/M /Missing] [/N /Nomissing]
Affichage de la distribution de chaque champ spécifié
/M ou /Missing inclue les observations avec des données manquantes (.) pour le champ considéré.
/N ou /NoMissing: exclue les observations avec des données manquantes (.) pour le champ considéré.
/NC : Pas d'affichage des poucentages cumulés.
/D1 /D0: Nombre de decimals à utiliser pour les pourcentages.
Défaut : 2
Spécifier le design:
set table design freq=line[box][filled][...]
tables
tab
tables variable1 variable2 [variable3 ...][/N /Notable][/M /Missing][/S /Summary][/Q /Quiet]
Tabulation(croisement) de variable1 et variable2, stratifiée par variable3 ...
Le premier champ spécifié est horizontal (abscisses), le second vertical (ordonnées).
/Notable ou /n: ne pas afficher la table.
/Missing ou /m: inclue les données manquantes (.) dans la table.
/S or /Summary: affiche un résumé du Chi2, p, valeurs attendues….
/Q or /Quiet: Ne pas afficher la table
Les
pourcentages, etc. contrôlés par by
set table definitions – voir ci-dessous
Les résultats sont stockées dans des variables résultat.
var results pour en afficher les noms et la structure.
Specifier
le design:
set table design stat=line[box][filled][...] ou set table design summary=line[box][filled][...]
Note:  les Odds Ratios, RR etc. pour les tables 2x2 sont obtenus par la commande epitables
epitables
etab
epitables conséquence exposition [variables de startification][/T /Table]
Table croisée de la conséquence pour chaque modalité d'exposition, stratifiée par (jusqu'à 3 variables)
La conséquence est toujours exprimée horizontalement, l'exposition verticalement.
/Table ou /t: affiche toutes les tables intermédiaires. Autrement, seules les tables résumées sont affichées
/Q or /Quiet: Ne pas afficher les tables. Les pourcentages, etc. sont contrôlés par les commandes 
set table definitions – voir ci-dessous
Les résultats sont stockées dans des variables résultat. Utilisez 
var results pour en afficher les noms et la structure
Specifier
le design:
set table design stat=line[box][filled][...] ou set table design summary=line[box][filled][...]
stattables
stattab
stattables "by variables" /options /statistics
Show a collapsed table with summary statistics for all combinations of "by variables"
options:
/close : close current data and use summary data set instead Note !! any unsaved data will be lost
/save="filename" Save the summary table to a new file
/missing /m Include observations where byvariables have missing values
Statistics:
/mean /SD /max /min /p5 /p10 /p25 /p50 /p75 /p90 /p95 /sum
short forms, will show (contents):
/des (min median max)
/iqr (p25 p75)
/idr (p10 p90)
/isr (p5 p95)
/mv (counts of defined missing values and blanks)
ExampleStattab sex agegrp /Mean="weight,height" /Des="weight,height"

Specify design: set table design stat=line[box][filled][...]
set parameters for Tables Pour toutes les tables:
set table label=on[off] (Montre les libellés définis dans la commande  comment legal comme valeurs a la place des codes)
set table value=on[off] (Show values in table categories)
set table design [][stat][system][freq][summary]=line[box][filled][system]... (Défini le format des tables)
Tables avec  pourcentages :
set table percent=R[CT]  : Inclus les pourcentages pour les  Lignes (R) Colonnes (C) Totaux (T) 
set table percent format col="P1{}"     (Col Percents format, e.g. "P2 %"
set table percent format row="P1()"     (Row Percents format, e.g. "P0[]"
set table percent format total="P0[]"    (Row Percents format, e.g. "P0[]"
set table percent header="%" (Titre de la colonne  pour les  pourcentages)
Autres :
set table statistics="OR CHI RR EXACT" pour les commandes  epitables et tables
set table reverse=on[off]  pour la commande epitables (With on: tables are inverted (highest values in top left corner)
Top Basic graphs
bar bar variable1
vertical bar plot of a single field
set table label and set table value defines if labels and or values are shown on x-axis
boxplot boxplot variable1[/hideout]
Box and whisker plot of field. The box shows interquartile range (25-75) with median highlighted. Length of whiskers are at 1.5* interquartile range
/Hideout will hide outlier markers, which otherwise shows values outside the whisker boundary
histogram
his
histogram variable1[/xonly]
histogram plot of a single field
/Xonly: only include x values present in data, otherwise add non-existing x values
line line xvar yvar [yvar2] [yvar3 ...]
line plot of yvar against xvar; multiple y variables may be plotted against xvar
- line xvar will give a frequency polygon for xvar
scatter
sca
scatter yvar [yvar2 ...]
scatter plot of yvar against xvar; multiply y variables may be plotted against xvar
pie pie var1
pie chart of frequencies of the values of var1
Percentages can be incorrect in some instances
erasepng erasepng [/noconfirm] [/all]
Erases graph*.png files in current folder shown on statusbar left side. Confirm each erase.
/all includes ALL files of type png (*.png) regardless of name
/noconfirm NOTE: deletes without confirmation
Common Graph options .... /save="file.png[.wmf][.bmp]" /saver=.../xlabel="variable"
/text="x,y,text,box" /ti="title" /sub="subtitle" /noedit /nolegend

/save saves file with that name and type - default is png with name of current time. File cannot exist, To overwrite: set graph replacefile=on
/Text adds a textbox at x,y in pixels from top left, e.g. /text="120,50,my text,1" 1 or 0 indicates box.
/xlabel will use contents of variable indicated as labels along x-axis
/xtext=" " Use text as description below the X axis
/ytext=" " Use text as description to the left of the Y axis
/edit will open a form for editing all general graph options.
/xmin /xmax /ymin /ymax sets axis scales
/noxtick /noytick hides tickmarks on axes
/nolegend hides legend

Check the graph dialog for further options - paste and you will see.
Set Graph Colour=123456
Use this to select colour sequence for bar graphs and histograms.
Indicate 6 numbers from 0 to 9. Colour sequence codes are:
Black, Red, Blue, Green, Yellow, SkyBlue, Fuchsia, White, Gray, Aqua, Maroon
set parameters for Graphs set graph savetype=png[wmf][bmp]
set graph edit=on[off]
set graph show=on[off] (on works only for graphtypes png)
set graph clipboard=on[off] (copy graph to clipboard after creation)
set graph footnote=text (footnote for graphs - default: EpiData Analysis Graph)
set graph filename show=off[on] (show name of file below the graph)
set graph filename folder=off[on] (Include folder in graph file name)
set graph size x=value (width of graph, e.g. value=600)
set graph size y=value (height of graph, e.g. value=400)
set graph font size=value (font size - default 10. Titles are scaled relatively)
Top Further analysis
kwallis kwallis variable1 variable2 [variable3 ...]
Kruskall-Wallace analysis of variance, where variable2 ... are factors

Specify design: set table design stat=line[box][filled][...]
match match outcomefield riskfield matchfield
** currently uses the same syntax as tables and will perform stratified analysis, with matchfield indicating the strata
regress regress yvar xvar1 [xvar2 ...]
linear regression with yvar as the dependent variable
** currently will handle a maximum of 5000 records
Specify design: set table design stat=line[box][filled][...]
correlate
cor
correlate var1 var2 [var3 ...]
Calculate correlation coefficients between all variables. Record limits same as regression. ** if correlation is undefined a floating point error will be generated
Specify design: set table design stat=line[box][filled][...]
Top Special graphs
ichart ichart time measurement
SPC: I-chart showing overall mean, control limits and actual measurements variables "time" used for X-axis and "measurement" indicating finding (can be continous measurement or count) at that time
pchart pchart time count total
SPC: A P-chart is created with the proportion of count/total for time value.
time variable used as x-axis
The chart includes overall mean, control limits and proportions
P-chart is a process control type graph
runchart runchart time count
SPC: A runchart shows the median of count and the actual counts.
time variable used as x-axis
The chart includes median and indication of tests of special cause
Runchart is a process control type graph
options for process control charts [/break=value /notest /neglcl
/Break (one or more) will split the chart at that point (-s). Value can be date "dd/mm/yyyy" or "mm/dd/yyyy" of same format as the time field.
/notest: do not perform tests for special cause variation
/neglcl: show negative as well as positive lower control limit values
Principles and tests Many principles exist for SPC graph testing. EpiData Analysis implements these principles:
SPC charts use a time variable along the X-axis and the observation as the Y-value. I- and P- Charts have control limits calculated as center line ± 3 Standard Deviations (3 Sigma.). The graphs do not demand a specific number of observations. The assumption for using tests for special variation is that btw. 20 and 30 observations are included in each portion (break). With fewer observations the chance of a Type II error is larger (overlooking an actual special cause) nad with larger numbers of observations the chance of a type I error is larger (false positive test)
In SPC - Statistical Process Control Charts: Control Limits are NOT the same as Confidence limits
    Data types
  • Run-Chart: Counts of observations with centerline (median)
  • I-Chart: Counts of observations with control limits and centerline (mean)
  • P-Chart: Proportion of observations with control limits and centerline (mean)

    Tests indicate signs of "Special Variation" in the data. Criteria depend on the type of SPC Chart.
  • Type 1:
    • Run chart: Total number of runs and limits for expected number of runs. Expected numbers based on a standard table.
    • I-Chart and P-Chart: Special Variation occurs for each observation outside the control limits.
  • Type 2:
    In Run-, I- and P-charts: Eight or more points in sequence on the same side of centerline (shift in the process). Values on center line are excluded from the count. The test counts number of sequences of eight points.
  • Type 3:
    In Run-, I- and P-charts: Six or more points decreasing or increasing in sequence (Trend). Sequential values of same size count as one. The test counts number of sequences of six points.
Top Save & Clear output
cls cls
clears the results screen
logopen logopen [filename[.{html|txt}]] [/close] [/append]
start a log file
- without parameters, the open file dialogue is started
- optinal /Close will close an open logfile. Append adds to existing file
replacing existing logfiles controlled with set replace logfile=off [on]
logclose logclose
close the current log file
Top View data
browse browse [variable1 [variable2 ...]]
browse values in a spreadsheet for all variables listed
- without parameters, browse all variables
Note that browse is much faster than list
list list [variable1 [variable2 ...]]
show values on the screen for all variables listed, with one record per line and no limit to the width of the display
- without parameters, list all variables
Note that browse is much faster than list - browse will be extended, list will not
SET LISTREC
Turns showing of sequence number in listing on or off
Select or If the sequence is within current select or "if". if you use list with temporary if, the number is not the same as recnumber
Update Update [variable1 [variable2 ...]] [/id=field]
Allows grid editing of data
- without parameters, works on all variables
/id=field will add if id=value then field= new value to output when editing
Generate/change variables
define define var1 fieldtype [cumulative|global]
create a new variable based on an EpiData fieldtype (###, ___, <Y>, or valid dateformat)
- var1 will initially be missing in all records
- cumulative variables retain their values from one record to the next
- global variables retain their values following a close command and are like constants (only one value)
gen gen var1 = expression | resultvar
create a new numeric variable based on the expression, or equal to a constant from a result variable
- equivalent to define and let, with the variable type implied by the expression
- if the result of expression is boolean, variable1 will be 0 (FALSE) or 1 (TRUE)
- Result variables are created by some commands, e.g. means and describe
IF the user specifies type, that type of variable is generated:
gen s var1 = expression
gen d var1 = expression
gen i var1 = expression
gen f var1 = expression
Compare variables if you use gen .... if ... with define ...
if ... then ...
.
generate generate value
creates a new empty dataset with value records. E.g. for simulation or testing.
- note the difference to gen command, which creates variables.
if ... then if (logical_expression) then [let] ... [else [let] ...]
evaluates logical_expression for each record; the else clause is optional
- for complex logical expressions, use parentheses; they are optional for simple expressions
- some other commands might work, but only let is practical
let [let] var1= expression | resultvar
assign a value to an existing variable; the word let is optional
- if the result of expression is boolean, var1 will be 0 (FALSE) or 1 (TRUE)
- only means and describe commands create result variables
recode recode variable1 to var2 values1 = newval1 [values2 = newval2 ...]
create or change codes for subgroups of records
- values1 takes one of three forms: a single value, a series of values separated by commas, or a range of consecutive values like 7-12 or "A"-"D"
e.g.recode v1 to v2 lo-18.499=1 18.50-hi=2 values up to 18.50,but not 18.50 gets the value 1
e.g. recode x lo-3.00=1 3.0001-4.0000=4 4.0001-5.49000=5 5.5-hi=7
- if to var2 is omitted, variable1 the original values will be lost. use
recode variable1 to var2 by value
- the variable1 values will be recoded to a string variable with labels indicating the limits.
E.g. recode age to agegroup by 10 to recode age variable to 10 year age groups.
Note: define agegroup before recoding define agegrp _______________
EpiData shows the if ... then statements which are actually doing the recode
Label data
labeldata labeldata "text"
Assign the descriptive text as a label for the data file.
An existing label will be replaced with the new one.
To keep the label you must save the data.
label label var "text"
Assign the descriptive text as a label for the variable.
An existing variable label will be replaced with the new one.
To keep the variable label you must save the data.
Top Clean up - stop
close close
stop using a dataset
- all unsaved variables and changes to existing fields will be lost
- global variables will remain in memory
quit or exit quit
exit
Exits from EpiData Analysis. Closes any open output file.
NOTE: To save data in memory before closing use the savedata command.
Automatic save of command history is done on exit. Filename defined by "set command history filename", default temp.pgm
If you write exit or quit in command prompt no confirmation question will be asked.
savepgm savepgm filename[.pgm]
saves recent commands in a program file
- without a parameter, the save file dialogue is opened
Automatic save of command history is done on exit. Filename defined by "set command history filename", default temp.pgm
clear command buffer clh
Clears the buffer of previous commands.

- It is the same list shown when pressing F7
Top Set parameters
set set [parameter=value]
set
change the value of a EpiData "set" parameter
- without parameters, provides a list of available parameters and their current values
- Add the set definitions to the file Epidatastat.ini file to modify from default
values can be a number, text or ON/OFF, see table below
offoff
Option Value Comments or function
set echo on
set editor print info on
set fillchar " "
set graph clipboard on
set graph edit off
set graph font size 10
set graph filename show
set graph filename folder
set graph replacefile off
set graph footnote text
set graph replacefile off
set graph save on
set graph savetype png
set graph show on
set graph size x 400
set graph size y 300
set command history on Add single lines from a pgm to command history, such that you can scroll with arrow keys
set command history filename temp
set listrec off Turns showing of sequence number in listing on or off
Note: if you use list with temporary if, the number is not the same as recnumber
set number format %8.2f
set print preview cm on
set read deleted off
set replace datafile off
set replace logfile off
set show command on
set show command history off
set show command prompt on
set show commandtree off
set show error on
set show info on
set show mainmenu on
set show result on
set show systeminfo off
set show toolbar on
set show worktoolbar on
set start page start.htm Show this page when analysis is started (must be html). Note F1 opens info.htm placed where the exe of EpiData Analysis is placed
set statistics on
set style sheet "out.css" File name is saved in output without path.
Remember to copy the file with logfiles
set style sheet external on Reference to style sheet file, instead of adding contents of style sheet to each html file
set to off for a self contained output file
set table design line
set table design freq line
set table design graph graph
set table design stat filled
set table design system system
set table rotate on Will transpose variables such that highest value of case and outcome are shown in top left 2x2 cell
set table label on Show defined category labels in tables
set table percent r
set table percent format col p1()
set table percent format row p1{}
set table percent format total p1[]
set table percent header %
set table statistics or rr chi exact
set table value off
set var name on Show name of variable in tables. When OFF remove the name if the first part of the label is equal to the name
set var label on Show variable label in tables
set viewer font charset ISO-8859-1
set viewer font name "Verdana,Fixedsys" Always include at least one proportional and one fixed font
set viewer font size 12
set window font size 12
Top Information
type type "Text to display [@$result1] " [/class=x] [/h1] [/h2] [/h3] [/h4] [/h5]
echo Text to display [@$result1]

display text on the screen;
if options are not used the text will added as a standard paragraph (html: < p >)
Options adds html specifications: /class: (html: <p class= > text </p>). (h1..h5: <hx> text </hx>)
result or globally defined variables may be displayed by putting @ before the variable name
title title "Text to display [@$result1] "
Display text on the screen as (html: <h1> text </h1>)
result or globally defined variables may be displayed by putting @ before the variable name
show show filename"
Add the contents of "filename" to the output window

The file must be plain text, e.g. NOT a word processor file, but may contain HTML formatting blocks without header.
variables variables or var
list variable names, types, formats and labels
var drop
drop
var drop variable1 [variable2 ...]
remove the listed variables from memory
var keep
keep
var keep variable1 [variable2 ...]
Remove all variables not listed from memory
var results var results
list all current result variables and their values
- means, describe, tables and other estimation commands create result variables, e.g. $mean1 or $count
All result variables are cleared when running a new command, except for $assert and $assert_error,
See var temp clear and runtest
var temp clear var temp clear
Removes ALL result variables and all tempory global variables defined as global
$assert, $assert_error and other internal variables are also cleared
Version Version"
Compare current version of EpiDataStat.exe with latest version (requires internet)

Note: No information is transferred from your PC
Latest version is read from Http://www.epidata.dk/version/epidatastat.version if you are connected to internet.
assert assert if (logical statement)
Check all data against the logical statement and return nothing if no errors occurred. Return text "Assert failed" if one or more records failed.
E.g. assert (pregnant = "Yes" and age < 40) or (pregnant = "No")
? ? (statement)
Show result of statement, e.g. a calculation or logical check. Does not depend on or check any data.
E.g. ? 241/34
? (23>19)
? "a " + "b " + "c"
Top Special data handling
relate relate keyvar filename[.rec]
relate the current data file to another data file based on keyvar
savedata savedata filename [field list]
Save a copy of all variables in memory to a new file - file cannot exits
To overwrite: set replace datafile=on Could overwrite your data !!
Saves all variables, but only records included in current select
aggregate
agg
aggregate variables /options /statistics
Aggregate and optionally save the summary data to a file
See explanation of options and statistics in the command Stattables To overwrite: set replace datafile=on Could overwrite your data !!
Respects current select
sort sort variable1 [variable2 ...]
sort the current dataset by one or more variables
output output {describe ... | means ...}
Command replaced by new command aggregate
route command replaced by SAVEDATA and LOGOPEN commands
write command replaced by SAVEDATA and LOGOPEN commands
Top Disk commands
cd cd "directory name"
change the working director
copyfile copyfile "filespec1" "filespec2"
copy file specified by filespec1 to new file specified by filespec2
- filespec must identify only one file - do NOT include wild cards (* or ?)
erase erase filename
permanently erase file specified by filename
- filename must identify only one file - do NOT include wild cards (* or ?)
rename file use copy and erase
To rename a file use copyfilefrom the existing file
Afterwards you can erase the existing file with erase.
dir dir [filespec]
list files in a directory
- filespec may include wild cards (* or ?)
Define design by set table design system=line[box][filled][system]...
dos
!
dos text
execute any valid MS-DOS command and return to EpiData
- dos command will open an MS-DOS window
Top Programming aids - not normally used in interactive mode
* * [any text]
Use to document programs, usually as the first character in a line. * is not recognized in interactive mode.
// [any command] // [any text]
Use to document programs and may appear anywhere on a line. // is recognized in interactive mode.
imif IMIF (logical condition) then ..... [else] ..... endif
Use to divert course in a pgm file depending on parameters, which could be acquired by "? ?"
? ? [any command] [parameters] "?Prompt to user? [parameters]
The text between the two ? will be a prompt to the user to type a response, followed by <Enter>. The response will then be treated as part of the command.
For select if age<=?Maximum age to include?
if the user types 50 then EpiData sees select if age<=50
EpiData does no checking of the typed response before making the substitution.

Functions available in EpiData Analysis

  • Operators
  • In the following, takes indicates the variable type for each parameter and result indicates the type of the result of the function:
         s: string; b: boolean; d: date; i: integer; f: floating point; n: any numeric
    parameters may be variables read from fields, new created variables, or any expression that evaluates to the correct type

    Top String functions
    function takes result example
    length(str) s i length("Abcde") => 5
    lower(str) s s lower("Abcde") => "abcde"
    pos(instr,findstr) s i pos("Abcde","cd") => 3
    pos("Abcde","z") => 0
    substr(str,start,len)
    copy(str,start,len)
    s,i,i s substr("Abcde",2,3) => "bcd"
    copy("Abcde",2,3) => "bcd"
    trim(str) s s trim("Abcde ") => "Abcde"
    upper(str) s s upper("Abcde") => "ABCDE"
    Top Arithmetic functions (including Random numbers)
    function takes result example
    abs(x) n n abs(-12) => 12
    exp(x) n f exp(1) => 2.71828182845905
    frac(x) f f frac(12.34) => 0.34
    int(x)
    trunc(x)
    f f int(12.34) => 12.0
    trunc(12.34) => 12.0
    ln(x) n f ln(2.71828182845905) => 1
    ln(0) => missing
    log(x) n f log(10) => 1
    log(0) => missing
    power(x,a) n,n f power(2,3) => 8
    round(x,digits) f f round(12.44,1) => 12.4
    round(12.5,0) => 13
    sqr(x) n f sqr(4) => 16
    sqrt(x) f f sqrt(4) => 2
    ran(x) n n Random integer from 0 to x. gen integer x = ran(100)
    rnd(1) 1 f Random float from 0 to 1. gen float x=rnd(1)
    rang(mean,sd) f,f f Random based on mean and sd. Gen float=rang($mean1,$sd1)
    Top Trigonomety functions
    function takes result example
    arctan(x) f f arctan(1) => pi/2
    cos(r) f f cos(pi/2) => 6.12303176911189E-17
    cos(pi) => -1
    pi - f pi => 3.14159265358979
    sin(r) f f sin(pi/2) => 1
    sin(pi) => 6.12303176911189E-17
    others     tan(x) = sin(x) / cos(x)
    arcsin(x) = arctan (x/sqrt (1-sqr (x)))
    arccos(x) = arctan (sqrt (1-sqr (x)) /x)
    Top Date functions
    function takes result example
    date - d/i returns today's date; may be assigned to a date variable or an integer
    date(datestr) s d date("31/12/04") => "31/12/2004"
    datestr must be of form <dd/mm/yy> or <dd/mm/yyyy>
    date(datestr,fmtstr) s,s d date("12/31/04","mdy") => "31/12/2004"
    fmtstr must be "mdy" or "dmy"
    day(d) d i day("31/12/2004") => 31
    dayofweek(d) d i dayofweek("31/12/2004") => 5
    Monday=1, Sunday=7
    dmy(d,m,y) i,i,i d dmy(31,12,2004) => "31/12/2004"
    month(d) d i month("31/12/2004") => 12
    weeknum(d) d i weeknum("22/02/2001") => 8
    year(d) d i year("31/12/2004") => 2004
    Top Logic functions
    function takes result example
    and(b1,b2) b,b b and(1=1,2=2) => TRUE
    and(1=1,1=2) => FALSE
    iif(b,x,y) b,any,any b iif(1=1,2,0) => 2
    iif(1=2,sqrt(4),sqr(4)) => 16
    or(b1,b2) b,b b or(1=1,1=2) => TRUE
    or(1=2,2=3) => FALSE
    not(b) b b not(1=1) => FALSE
    not(1=2) => TRUE
    Top Conversion functions
    function takes result example
    boolean(x) n b boolean(x) => TRUE, for any non-zero x
    boolean(0) => FALSE
    integer(x) f i integer(1.23) => 1
    float(i) i f float(1) => 1.000
    string(x) n s string(1.23) => "1.23"
    Top Test and special functions
    function takes result example
    lre(x,y) n n lre($mean1,1.23456789123456) returns number of digits precision of $mean1
    samenum(x,y,z) n n ? samenum($mean1,1.23456789123456,10-7) returns true or false indicating if |(x-y)| < z
    samenum(x,y,z) n n ? samenum($mean1,1.23456789123456) returns true or false indicating if |x| = |y|
    var[recnumber] n data value Not a function, but a way to get a value for a given record. E.g. gen i x=age[recnumber] = age[recnumber-1]

    Top Operators used in EpiData Analysis
    operator syntax result meaning example
    + n+n n addition 1+2 => 3
    + s+any
    any+s
    s concatenation "A"+"B" => "AB"
    "A"+1 => "A1"
    + d+n d date addition "30/11/2004"+31 => "31/12/2004"
    - n-n n subtraction 2-1 => 1
    - d-d n date subtraction "31/12/2004"-"30/11/2004" => 31
    - d-n d date subtraction "31/12/2004"-31 => "30/11/2004"
    * n*n n multiplication 2*3 => 6
    / n/n n division 5/2 => 2.5
    5/0 => missing
    div n div n i integer result of division 5 div 2 => 2
    5 div 0 => missing
    ^ n^n f exponentiation 5^2 => 25
    4^0.5 => 2
    ( ) group expressions (5*(2+4))/2 => 15
    5*2+4/2 == (5*2)+(4/2) => 12
    < n<n b less than 1<2 => TRUE
    > n>n b greater than 1>2 => FALSE
    <= n<=n b less than or equal 1<=2 => TRUE
    2<=2 => TRUE
    >= n>=n b greater than or equal 1>=2 => FALSE
    2>=2 => TRUE
    <> n<>n b not equal to 1<>2 => TRUE
    1<>1 => FALSE
    @ @var1 value substitution used in any command, replaces @var1 with the contents of var1 before executing the command
    $ $resultvar result value used in let or gen, replaces $resultvar with the value of resultvar