Commands only available in EpiData Analysis Classic: Download Software |
|
|
|
Syntax for all commands: command <variables> [!option] [!option := a|b] If you are in doubt of when to use double quotes "" and when not, the rule is: |
↥ Read & Save Data | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
read |
read [{"<filename>" | <expression>}] [!options ...] Read a copy of the data file into memory. Note: The file name, including the file extension must be contained in " ". If you use a case sensitive operating system (Linux) then the case of filename and extension is important. Examples: read "bromar.rec"; // complete filename provided read "bromar" + ".epx"; // expression using two strings in concatenation new global fn string; fn := "bromar.epx"; read fn; // expression using the variable fn |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
save |
save [{"<filename>" | <expression>}] [!replace] [!format:="{stata|epidata|csv}"] [!force] Save a copy of all variables in memory to a file, to use the data again
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
↥ Append, Merge & Aggregate | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
append |
append [<var1> <var2>...] [!ds := <dataset>] [!fn := <filename>]
Add observations after all observations in current file Options:
Only fields with same name as variables in memory will be read. Variables from previous read which are not in the appended file will be set to missing for the appended observations. See variables on using referenced variables for this command |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
merge | merge [<key1> <key2> ...] [!fn [:= "<filename>":]] [!ds := <dataset>] [!table] [!combine | !update | !replace]
Merge the current data file with another dataset file based on key variable(s). The result is a NEW dataset which is added to the top level of the project.
After merge the variable mergevar indicates source of information for each observation (records).
Examples: // Load a project read "Clinical Example.epx"; // A: Internal merge (1 related dataset) // Since the current used dataset only has a single related dataset, // there is enough information provided by the key variable to combine to two datasets. merge; // B: Internal merge (2+ related datasets) // The currently used dataset have 2 or more related datasets, so we need to use the // option !ds := <id> to specify which dataset we want to merge with. list ds // Use list to see which dataset id's you have in the project merge !ds := labdata // C: External merge (1+ dataset in external file - e.g. a .csv file) // In order to merge with an external file the key variables to merge on must be provided merge patientid !ds := "PatientNames.csv":labdata // D: External merge (2+ datasets in external file) // In order to merge with an external file that has 2+ dataset, both the key variables // AND the dataset you wish to merge with must be provided! merge patientid !ds := firstdataset !filename := "PatientNames.epx" See variables on using referenced variables for this command |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
aggregate agg |
aggregate [<var1> <var2>...] [!options] Aggregate - collapse - combine - data when you wish to change from individual to group level./p> See variables on using referenced variables for this command Overall options:
Summary statistic options:
// define a global vectore for column texts: new global columntxt[5] string; columntxt[1] := "Group"; columntxt[2] := "N Total"; columntxt[3] := "n (observed)"; columntxt[4] := "Mean"; columntxt[5] := .; agg sex age family !hd:=columntxt !mci:=economy !mci:=children ; |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
↥ Using datasets & Sorting | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
use |
use <dataset>
Change the active dataset of a project. See variables on using referenced variables for this command read "Clinical Example.epx"; list dataset; use datafile_id_2; |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
sort |
sort variable1 [variable2 ...] [!descending] Sorts the current dataset based on the given variables. Sort respects current select!
See variables on using referenced variables for this command |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
↥Create new content | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
new project new p |
new project Creates a new empty project, e.g. for simulation or testing.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
new dataset new ds |
new dataset dataset [!options...] Create a new dataset for the project. Use the options to specify relations between datasets. If the command completes successfully, the newly created dataset is automatically used
See variables on using referenced variables for this command |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
new variable new var new v |
new variable variable <type> [:= expression] [!options...] Create a new variable of a given type and optionally assign the value in expression. The variable type and expressions type must be compatible. Variables contain a value for each observation. If no expression is given, all values will be missing.
new variable v1 integer := 1 + 2 * 3 - 4; new variable v2 float := (2 * pi) * 5; new variable v3 string := "Hello World!"; new variable v4 time := now(); new variable v5 boolean := (2 > 3); new variable v6 date := today(); Examples where a value depends on other variables: new variable v1 integer := v14 + v17; // v1 is equal to sum of v14 and v17 new variable age date := integer((today() - dateborn)/365.25) // calculated age in whole years See variables on using referenced variables for this command |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
new global new g |
new global variable <type> [:= expression]
new global variable[<integer expression>] <type> [:= expression]
Create a new global parameter variable with a given type and optionally assign the value given in an expression. The global variable or parameter has only one value, whereas a standard variable has one value for each observation. The global variable type and expressions type must be compatible otherwise an error will occur. Global variables can for most parts be used like as a regular variable, but they cannot be evaluated as a vector. If the variable name is followed by square brackets [...], then a global vector is created, where each entry can be individually accessed using e.g. g[3] := 20. If a value is assigned when creating a new global vector all entries of the vector will have the same value! Examples: new global g1 integer := 1 + 2 * 3 - 4; new global g2 float := (2 * pi) * 5; new global g3 string := "Hello World!"; new global g4 time := now(); new global g5 boolean := (2 > 3); new global g6 date := today(); new global g7[10] integer := 10;See variables on using referenced variables for this command |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
new valuelabel new vl |
new valuelabel valuelabel <type> (<value> , <label>) (...) [!m := <value>]
Create a new value label set with a given type (boolean not supported) and assign at least one (value, label) pair. Each (value, label) pair will be added to the newly created set. The datatype of the value MUST match the defined datatype for the value label set itself. It is not possible to create an empty valuelabel set. Note: An empty set will restrict data entry to system missing only! Note: The valuelabel name must be unique; it cannot be the same as any variable. A useful practice is to start the valuelabel name with an underscore: _
See edit valuelabels for more advanced use of variables and loops to create additional valuelabels See variables on using referenced variables for this command |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
↥List content | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
browse |
browse [variable1 [variable2 ...] ] [options] Show the variables mentioned in a spreadsheet grid
See variables on using referenced variables for this command Note that browse is much faster than list |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
list data list d |
list data [variable1 [variable2 ...]]
Show values on the screen for all variables mentioned, with one observation per line (not limited by the width of the display)
Note that browse is much faster than list. Note:When list follows select: the sequence number is within the current select, not for the whole dataset.See variables on using referenced variables for this command |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
list project list p |
list project
Shows a brief overview of the project
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
list dataset list ds |
list dataset
Shows a list of datasets for the project
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
list variable list var list v |
list variable
List currently defined variable names, types, formats and labels |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
list valuelabel list vl |
list valuelabel
Shows the full list of all valuelabel sets. Each set is listed individually as value/label pair and marked whether a value is considered missing or not. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
list results list res list r |
list results
List all current result variables and their values. means, describe, tables and other estimation commands create result variables, e.g. $mean[1] or $count. All result variables are cleared when running the same command again. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
list global list g |
list global
List currently defined global variables and their types and value. Global variables contain a single value and global vectors contain multiple values. The list shows both types. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
↥Edit definitions of projects, datasets, variables and labels | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
edit project edit p |
edit project Edits a project.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
edit dataset edit ds |
edit dataset dataset1 [!options...] Edits an existing dataset in the project.
See variables on using referenced variables for this command |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
edit variable edit var edit v |
edit variable variable1 [!<options>...]
Edit the metadata of variable1. The options specify which metadata are changed, multiple options may be used at once
Note: Data values are NOT changed! Even if the new length or decimals is shorter than actual content. To keep the changes made you must save the data.See variables on using referenced variables for this command |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
edit valuelabel edit vl |
edit valuelabel valuelabel1 [(<value> , <text>) ...] [!m := <value>] [!delete := <value>] [!nomissing := <value>]
Edits an existing value label set and optionally assign any number of (value, label) pairs.
See variables on using referenced variables for this command |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
edit data edit d |
edit data [!md] [!nomd] [!mv] [!nomv]
Edit the status of observations
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
↥Deleting content | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
drop dataset drop ds |
drop dataset dataset1 [dataset2 ...] Remove the listed datasets (and related datasets) from memory See variables on using referenced variables for this command |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
drop data drop d |
drop data [!del] Drops all data within current select from memory. Save the data first if you wish to keep any changes.
read "bromar.epx"; select (id > 1000) do drop data; // Drops all observations where id > 1000, but keeps the rest. read "bromar.epx"; drop data !del ; // drop all observations "marked for deletion" |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
drop variable drop var drop v |
drop variable variable1 [variable2 ...] Remove the listed variables from memory See variables on using referenced variables for this command |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keep variable keep var keep v |
keep variable variable1 [variable2 ...] Keep the variables listed, and DROP all other variables from the current dataset in memory Hint: To get a dropped variable back into memory again, You must read the data from disk. See variables on using referenced variables for this command |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
drop global drop g |
drop global [variable1 ...] [!all [:= <type>]] Remove the listed global variables from memory
new global i1 int; new global i2 int; new global f1 float; new global f2 float; new global s1 string; drop global i2; // drops i2 drop global !all := "float"; // drops f1 and f2 drop global !all; // drops i1 and s1 (because they are left) See variables on using referenced variables for this command |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
drop valuelabel drop vl |
drop valuelabel valuelabel1 [valuelabel2 ...] Remove the listed value label sets from memory. If the set is assigned to a variable, then this assignment is automatically removed See variables on using referenced variables for this command |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
↥ Select observations | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
select ... do |
select <logical expression> do <statement> Work with selected observations (subgroup of data) Select requires a command or a begin ... end segment following the expression. After the command(s) are executed, the dataset is no longer reduced. Note: The commands merge, append, save cannot be used with the select ...do ...; statement.It is possible to make nested selects which will combine the selects. Example: select (V1 > 3) do begin count; // observations where (v1 > 3) select (V1 < 4) do begin count; // observations where ((v1 > 3) and (V1 < 4)). end; end; |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
↥ Changing flow of the script | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if ... then ... else ... |
if <logical_expression> then <statement or command> [else <statement or command>] This is a "flow" control statement - which will evaluate logical_expression once and execute the command(s) following then
when the logical expression is true. Note: This statement is not normally used to change values of variables (see the example below).
The else clause is optional and is only executed if evaluation of the logical expression is false. For complex logical expressions, use parentheses for clarity. if (dayofweek(today()) = 1) then freq v12 // will show variable v12 on mondays else freq v13; // will show variable v13 on other days of week. Note: The flow control of "if ... then .... was completely different in EpiData Analysis Classic v2.2. // In Analysis 2.2 to change all system missing values in V1 with the value 99 if (V1 = .) then V1 := 99; // To do the same in current Analysis use this syntax: select (V1 = .) do V1 := 99; |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
for .. to .. do |
for <var> := <start value> to|downto <end value> do <statements>; Loops through the integer values from start to end either in ascending order (to) or descending order (downto). new variable ID integer; // this creates the new ID variable new global i integer; for i := 1 to size(@dataset[1]) do ID := i; // variable ID now has the sequential number that each observation has in a dataset. // You may sort the data before doing so. //Note: Another way to do this without a for command is new variable ID integer := _n; // _n is shorthand for the current record number See variables on using referenced variables for this command |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
for .. in .. do |
for <var> in [<value1>, <value2>, ...] do statements; Loops through the values one by one, assigning it to <var> The only restriction in this loop is that the datatype of <var> and <value> must be the same! Examples: new global I integer; for I in [1, 3, 5, 7, 9] do ? I < 10; // "regular" integer loop. new global F float; for F in [1.1, 3.3, 5.5] do ? fraction(F); // Looping with floating values new global S string; for S in ["Denmark", "Norway", "Sweden", "Finland"] do ? S + " is a nordic country";See variables on using referenced variables for this command |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
↥ Reordering variables and ? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
reorder |
reorder var1 [var2 ...] [!options] Reorders the variables specified. This can be used to place specific variable together and used with variable expansion
If no options are specified, the default is to place the variables before all other variables in the list. Use F3 or "list variable" to show the current order of variables. Examples: read "bromar.epx"; // Load the project reorder kmgrp agegrp decgrp; // Moves the variables kmgrpm, agegrp, and decgrp to the front of the list reorder age km !before := agegrp // Moved the variables age and km in front of agegrpSee variables on using referenced variables for this command |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
recode |
recode <from variable> to <to variable> !by := <value> [!options]
recode A to B (<lower bound>, <upper bound> [, <Label Text> [, <Label Value>]]) .. [!options] Recode transforms data from the <from variable> to the <to variable> but groups data within the same range to a given values.
See variables on using referenced variables for this command
Hint: If the user indicates recoding of system missing values with the !m option,
then the user must ensure this does not conflict with other recoding. The <to variable> variable can have sysmis (".") in the followoing ways:
See variables on using referenced variables for this command read "bromar.epx"; // Load the project recode age to ag10 !by := 10 // Recodes data in intervals of 10: [0, 10) [10, 20) [20, 30) .... recode age to ag (0, 10, "Label A") (10, 25) (30, 50, "Label B", 2) // Recodes data to intervals: [0, 10) [10,25) [30, 50) // note: [0, 10) will have value label: 0 = "Label A" // [10, 25) will have value label: 10 = "10 - 25" (default value/label naming scheme) // [30, 50) will have value label: 2 = "Label B" |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
? |
? <expression> Show result of an expression. It is posible to use all types of variables (standard, results or global) in the expression. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
↥ Change variable content | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Assign the value given in an expression. The variable type and expressions must be compatible otherwise an error will occur. Here all observations get the same value: v1 := 1 + 2 * 3 - 4; v2 := (2 * pi) * 5; v3 := "Hello World!"; v4 := now(); v5 := (2 > 3); v6 := today(); It is also possible to assign a value to individual entries of a variable: v1[1] := 3; v2[2] := 31.41596; v3[3] := "It works!"; v4[1] := Createtime(12, 34, 56);If you specify a conditional (depend) rule based on other variables the change only occurs for the subgroup defined by the select statement: select (v1 = 0) do v17 := 17; select ((v1 = 0) and (v2 = .)) do v17 := 27;Functions may be used: select (age = .) do age := integer((today() - dateborn)/365.25) // calculated age |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
↥ Tables & Frequencies | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
count |
count Counts number of observations. Count may be used with select to count within a subgroup Result variable: $count. Use list results for details |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
freq fre |
freq variable1 [!<option> ...] Frequency distribution for variable1 See variables on using referenced variables for this command
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
tables tab |
tab <column variable> <row variable> [!<option> ...] The tables (brief: tab) command shows a cross tables for the variables chosen. See variables on using referenced variables for this command The default sorting for the cross tables is increasing value, regardsless of any valuelabel for the variables. Use options below to change the sort order!
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ctable cta |
cta <column variable> <row variables> [!<option> ...] The ctable (brief: cta) command summarizes a series of cross tables for the first variable against each of the following variables. See variables on using referenced variables for this command The ctable command takes the following options, which have the same meaning as in the tables command.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
↥ Means and Descriptive Statistics | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
means |
means variable1 [!by=variable2] [!t] Basic descriptive statistics for variable1, optionally stratified by variable2 with analysis of variance See variables on using referenced variables for this command
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
describe |
describe variable list [option list] Basic descriptive statistics and frequencies for a group of variables See variables on using referenced variables for this command Use any combination of options to customize the output
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
↥ Consistency and Validity Check of data | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
check data |
check data [var1 ...] Use this command to perform a check of the data in selected variables (if no variable are specified, then ALL variable are checked).
See variables on using referenced variables for this command |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
check key |
check key [var1 ...] Use this command to perform a check of the data in specified variables whether the data is unique and represent a key. See variables on using referenced variables for this command |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
check relate |
check relate Performs a check on data and whether all observations have a valid parent observation Examples: read "related_data.epx"; // Load the project use child_dataset; // Change dataset to a related dataset check relate; // Perform the check from the child dataset "upwards" to the parent. // Must be repeated if you have more levels |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
check study |
check study Performs a check on the study information of whether it is filled or not. Examples: read "samplev3.epx"; // Load the project check study; // Perform the check |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
↥ Reports | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
report users |
report users If a project is using Extended Access control, this command will show a condensed report of the log entries and a list of failed login attempts. If the project is not using Extended Access control, an error will be displayed. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
report val |
report validate [var1 var2 ...] [!options] Compares two dataset / projects against each other, validating the data content and outputs a report of differences based on the comparison. The variables var1 .. varn denotes the sorting variables. This is required if not comparing whole projects OR if the datasets does not contain and key variables.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
report cby |
report cby [var1 var2 ...] [!options] Compares the combination of variables across several datasets. The variables var1 .. varn is considere a "key" and each unique combination of this key is counted across all the specified datasets. The output is a report with a condensed table of the found keys and a complete table with the found unique key values and the count of these in each dataset.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
↥ Disk commands | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cd |
cd ["<directory path>"] Change the working directory (folder) to the specified path. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ls dir |
ls ["<directory path>"]
list files in a directory |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
erase |
erase "<file name>"
Delete the file from disk. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
↥ Set parameters | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
set |
set ["parameter"] := ["value"]
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
↥Labeling and formatting data | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Valuelabels |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Variable Labels |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Formatting |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
↥Variable types | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
integer int i |
A variable (standard, result or global) that contains an integer value. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
float f |
A variable (standard, result or global) that contains an floating point value. Note: all floating points shown on screen appear in the current national setting (locale), but input (from editor or command line) must always use "." (period) as the decimal separator. The saved data in a given project can be used in different national settings without giving problems or need for conversions. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
string str s |
A variable (standard, result or global) that may contain any string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
boolean bool b |
A variable (standard, result or global) that contains only true or false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
time t |
A variable (standard, result or global) that contains a time value. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
date d |
A variable (standard, result or global) that contains a date value. All new date variables created will be a DMY type, but this may change in the future. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
↥Using Variables and references | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Variable Expansion var1 - var4 va* var? |
Any command that accepts more than one variable can use the following schemes for variable expansion.
It is possible to combine "*" and "?" for more elaborate expressions, but neither can be combined with "-" Variables for expansion cannot start with the "*" or "?", but must start with a "normal" character. Example: // Consider the following set of variables (and in that order): // V1, V2, V3, V4, V10, V11, V100 list data V2 - V10; // V2 - V10 is expanded to the variables V2, V3, V4 and V10 list data V1* ; // V1* is expanded to V1, V10, V11, V100 because * can be "" (empty character) and "0", "1" and "00" list data V? ; // V? is expanded to V1, V2, V3 and V4, because ? can be be replaced by "1", "2", "3" and "4" but not any other. list data V1??; // V1?? is expanded to V100 only! Referenced variable may also be used in the expansion. These will be evaluated before the expansion! |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Referenced Variable @{variable1} |
With a referenced variable, you essentially use the content of another variable (global, result) to provide the variable name. Examples: new global gvar1 string := "sex"; read "bromar.epx"; freq sex; // Outputs a frequency table for the variable "sex" freq @{gvar1}; // Does the same as above, because the content of gvar1 is "sex"This can be combined with indexing of a variable. Using some of the builtin result variables like $dataset and $variable: new global i integer; for i := 1 to size($variable) do begin // Here we output the name of all the variables: // - not using the @{..} because we want the content of the $variable result var. ? $variable[i] // Here we do a frequency table of the variable. // - using @{..} because "freq" needs a variable and not the content of $variable freq @{$variable[i]} end;The Variable inside the @{..} may itself be another reference (with or without index), making it possible to combine multiple levels of references. new global f string := "age" new global g[3] string := "f"; // All entries have the value "f", but that is fine for this example. new global h[3] string := "g"; // All entries have the value "g", but that is fine for this example. // The line below is a valid construction, which evalutes the following way // 1: h[1] is evaluated into the string "g" // 2: "g" is used in @{"g"}, which means - use the content of g as a variable // 3: g[1] is evaluated into the string "f" // 4: "f is used in @{"f"}, which means - use the content of f as a variable // 5: @{f} is evalued to the variable AGE // 6: The command freq is run on the variable AGE. freq @{ @{h[1]}[1] }; Example of how to loop over a referenced variable: // you wish to estimate the time for parts of an analysis and have created a number of time stamps: new global tx t:= now(); // where x is 1 , 2, 3 etc. // now to display these and the difference: - assume you had five of these: new global i i; for i:= 1 to 5 do begin ? i + " time: " + @{"t" + i}; // this works becaus the parenthesis will be t1 t2 t3 etc. end; // now also calculate the difference in time between the two: new global tdif t; // tdif is a time difference for i:= 2 to 5 do begin tdif := (@{"t" + i} - @{"t" + (i-1)}); // notice again the (tdif = t2 -t1 ) when i was = 2 ? i + " difference : " + tdif; end; |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
↥ Programming aids - not normally used in interactive mode | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
runtest |
runtest ["<directory path>"]
Run all pgm's in a given directory (folder) to verify function. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
run |
run ["<filename.pgm>"] Execute sequence of commands saved in a pgm file |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
↥ Clean up - clear screen and history | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
close |
close Stop using a project - all unsaved variables and changes to existing variables and labels will be lost - global variables will remain in memory |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cls | cls Clear the output screen |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
clh | clh Clear the history of commands |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
reset | reset Complete reset of all parameters of the program! |
↥Functions available in EpiData Analysis | |||
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; t: time; i: integer; f: floating point; n: any numeric; v: variable parameters may be variables read from fields, new created variables, or any expression that evaluates to the correct type. |
↥ String functions | |||
function | takes | result | example |
length(str) | s | i | length("Abcde") => 5 |
pos(instr, findstr) | s, s | i | pos("Abcde", "cd") => 3 pos("Abcde", "z") => 0 |
substring(str, start, len) | s, i, i | s | substring("Abcde", 2, 3) => "bcd" |
trim(str) | s | s | trim("Abcde ") => "Abcde" trim(" Abcde") => "Abcde" |
lower(str) | s | s | lower("Abcde") => "abcde" |
upper(str) | s | s | upper("Abcde") => "ABCDE" |
concat(X, s1, s2, ..., sn) | s, any, ... | s | Concat(...) concatinates values s1 -> sn into a string. If any of the sx parameters return system missing it will be replaced by the value of X concat("X", "a", v1[_n]) => "aX" if v1 is missing, else a + the value of v1 Note: for user defined missing values, the actual value is added to the string. |
↥ Arithmetic functions (including Random numbers) | |||
function | takes | result | example |
abs(x) | n | n | abs(-12) => 12 |
exp(x) | n | f | exp(1) => 2.71828182845905 |
fraction(x) | f | f | fraction(12.34) => 0.34 |
ln(x) | n | f | ln(2.71828182845905) => 1 ln(0) => missing |
log(x) | n | f | log(10) => 1 log(0) => missing |
round(x, digits) | n, d, t | f | round(12.44,1) => 12.4 round(12.5,0) => 13 |
sqrt(x) | n | f | sqrt(4) => 2 |
random(x) | i | i | Random integer from 0 to x |
sum(n1, n2, ..., nn) | n, ... | n | Sums that values n1 => nn, but ignores the entries if they are either sys. missing or user defined missing |
↥ Trigonomety functions | |||
function | takes | result | example |
tan(x) | f | f | tan(0) => 0 |
arctan(x) | f | f | arctan(1) => pi/2 |
cos(r) | f | f | cos(pi/2) => 6.12303176911189E-17 cos(pi) => -1 |
arccos(r) | f | f | arccos(0) => pi / 2 |
sin(r) | f | f | sin(pi/2) => 1 sin(pi) => 6.12303176911189E-17 |
arcsin(r) | f | f | arcsin(0) => 0 |
↥ Date functions | |||
function | takes | result | example |
createdate(datestr) | s | d | createdate("31/12/2016") => 31/12/2016 The form of datestr is automatically detected, but if the string is ambiguous the preference is always DMY over MDY. If parts of the datestr are omitted, then these parts are filled with todays values. |
createdate(datestr, fmt) | s, s | d |
createdate("31/12/2016", "dmy") => 31/12/2016 createdate("12/31/2016", "mdy") => 31/12/2016 createdate("2016/12/31", "ymd") => 31/12/2016 |
createdate(d, m, y) | i, i, i | d | createdate(31, 12, 2016) => 31/12/2016 |
today() | - | i | returns today's date; may be assigned to a date variable or an integer |
day(d) | d | i | day(31/12/2004) => 31 |
dayofweek(d) | d | i | dayofweek(31/12/2004) => 5 Monday=1, Sunday=7 |
month(d) | d | i | month(31/12/2004) => 12 |
week(d) | d | i | week(22/02/2001) => 8 |
year(d) | d | i | year(31/12/2004) => 2004 |
↥ Time functions | |||
function | takes | result | example |
createtime(timestr) | s | t | createtime("12:34:56") => 12:34:56 The form of timestr is automatically detected. If parts of the timestr are omitted, then these parts are filled with 0 (zero). |
createtime(h, m, s) | i, i, i | t | createtime(12, 34, 56) => 12:34:56 |
now() | - | f | returns the time right now. It can be assigned to a time or float variable |
second(t) | t | i | second(12:34:56) => 56 |
minute(t) | t | i | minut(12:34:56) => 34 |
hour(t) | t | i | hour(12:34:56) => 12 |
↥ Logic functions | |||
function | takes | result | example |
b1 and b2 | b,b | b |
true and true => TRUE true and false => FALSE false and true => FALSE false and false => FALSE |
b1 or b2 | b,b | b |
true or true => TRUE true or false => TRUE false or true => TRUE false or false => FALSE |
b1 xor b2 | b,b | b |
true xor true => FALSE true xor false => TRUE false xor true => TRUE false xor false => FALSE |
not(b) | b | b |
not(true) => FALSE not(false) => TRUE |
↥ Conversion functions | |||
function | takes | result | example |
boolean(x) | any | b |
boolean(x) => TRUE, for any non-zero x boolean(0) => FALSE boolean("true") => TRUE, "true" text is case in-sensitive boolean(x) => FALSE, for any text other than "true" |
integer(x) | any | i |
integer(1.23) => 1 integer(31/12/2016) => 42735 integer("2") => 2 integer("a") => . Any input x that cannot be interpreted as an integer returns missing "." |
float(x) | any | f |
float(1) => 1.00 float("12,34") => 12.34 Any input x that cannot be interpreted as a float returns missing "." |
string(x) | n | s | string(1.23) => "1.23" |
↥ Identifier functions | |||
function | takes | result | example |
exist(x) | v | b | Returns true/false whether the provided identifier exist |
idtype(x) | v | i | Returns the type of the identifier provided. This function cal be used on all valid identifiers and the integer value returned have the following associations: 0: Global variable 1: Global vector 2: Regular Variable 3: Dataset 4: Valuelabel 5: Result Variable 6: Result Vector 7: Result Matrix Note: if using idtype(x) with the eval function "?", the output will be in text. |
datatype(x) | v | i | Similarly as to idtype(x) this function takes any variable, but in this case returns the type of date stored in the variable. The integer value return have the following associations: -1: Variable has no data type - e.g. a dataset variable. 0: Boolean 1: Integer 2: Auto Increment 3: Float 4: DMY Date 5: MDY Date 6: YMD Date 7: DMY Auto Date 8: MDY Auto Date 9: YMD Auto Date 10: Time 11: Auto Time 12: Uppercase String 13: String 14: Memo Note: if using datatype(x) with the eval function "?", the output will be in text. |
size(x) | v | i | Size returns the size/length of an identifier (if applicable). The function works as follows: Global & Result variables always have size 1 Global vector, Result Vector, Variable & Valuelabel return the length/size/count of elements/data Result Matrix is not implemented yet - it returns -1; Dataset returns the total number of observations (even if a select is applied). |
label(v) | v | s | Return the descriptive label of the identifier. This is only possible for variables and datasets. |
↥ Test and special functions | |||
function | takes | result | example |
lre(x,y) | n | n | lre($mean1, 1.23456789123456) returns number of digits precision of $mean1 |
iif(b, x, y) | b, n, n | n |
iif(..., true value, false value) evaluates the boolean expression (b) inline, and based on the result either returns the true value or false value. iif(2 = 3, "This is true", "This is false") => "This is false" |
samevalue(x, y, z) | x,y = n, d, t z = i |
b | samevalue($mean1, 1.23456789123456, 10-7) returns true or false indicating if |(x-y)| < 10z Best used for comparing floating point values. Since internal binary representation of two seamingly even numbers may differ, using x = y can fail. |
samevalue(x, y) | n, d, t | b | samevalue($mean1, 1.23456789123456) returns true or false indicating if x = y Essentially the same as calling samevalue(x, y, 15) |
cwd() | - | s | Returns the current working directory |
deleted([index]) | [i] | b | Returns true/false whether the record is marked for deletion. If no index is supplied the current record number is tested: select deleted() do edit data !nomd // selects current records marked for deletion and unmark them |
verified([index]) | [i] | b | Returns true/false whether the record is marked as verified. If no index is supplied the current record number is tested: select verified() do edit data !nomd // selects current records marked for deletion and unmark them |
↥ 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 | equal | 1 = 2 => FALSE |
< | 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 |
$ | $resultvar | result value | ? $count => 4027 |
↥ Startup options for EpiData Analysis |
epidataanalysis [options] Advanced users can start Analysis from the command line or via a batch file, depending on your operating system.
Example for Linux: ./epidataanalysis -i /path/to/startup.pgm |