Epi Info™ User Guide
Command Reference
Analysis Commands: SELECT
Description
This command allows an expression to be specified that must be true to process a record. It can also be called a data filter. If the current selection is Age>35, then only those records with age greater than 35 are selected. SELECT used alone without an expression cancels all previous SELECT statements. SELECT statements are cumulative until canceled. Therefore, Select Age > 34, Select Sex = “Male” will choose males over the age of 34. Cancel Select before doing Select Sex = “Female” because you will get only records that are male and female, or none at all.
Syntax
SELECT <expression>
- The <expression> represents any valid Epi Info 7 expression.
Comments
SELECT expressions are cumulative so that the two expressions:
SELECT Age > 35
SELECT Sex = “F”
are equivalent to
SELECT (Age > 35) AND (Sex = “F”)
Examples
Example 1: A subset of the data contained in the Food History table is selected. In this case, only records where the patient is female and interviewed after 04/15/2011, where the patient is male and interviewed after 06/01/2011 are selected to be in the subset. Note the use of parentheses to show relationships.
READ {.\Projects\EColi\EColi.prj}:FoodHistory SELECT ((DateofInterview > 04/15/2011) AND (Sex =”F-Female")) OR ((DateofInterview > 05/15/2011) AND (Sex = "M-Male")) LIST * GRIDTABLE
Example 2: A subset of the data contained in the Food History data table is selected. In this case, only records where the patient’s first name is “Pam” are selected to be in the subset. Note that “Huber” is not case sensitive, and the SELECT command would have also selected “HUBER” and “huber”.
READ {.\Projects\EColi\EColi.prj}:FoodHistory SELECT LastName = "Huber" LIST * GRIDTABLE
Example 3: A subset of the data contained in the Food History data table is selected. In this case, only records where the patient’s last name starts with the letters “Sch” and ends with the letter “r” are selected to be in the subset.
READ 'C:Epi_Info\Refugee.mdb':Patient SELECT LastName LIKE "Sch*r" LIST LastName
Example 4: A subset of the data contained in the Oswego data table is selected. In this case, only records where the patient is ill are selected to be in the subset.
READ {.\Projects\Sample\Sample.prj}:Oswego SELECT Ill = (+) LIST Name Age Ill
Example 5: A subset of the data contained in the Oswego data table is selected. In this case, all records except those that do not have a value for the TimeSupper variable (the field was left blank during data entry) will be selected to be in the subset.
READ {.\Projects\Sample\Sample.prj}:Oswego SELECT NOT TimeSupper = (.) LIST TimeSupper DateOnset Sex Ill
Example 6: A subset of the data contained in the Oswego data table is selected. Two SELECT commands have a cumulative effect so that the two expressions are equivalent to SELECT (Age > 30) AND (Sex = “Male”). Only records where the age is greater than 30 and the sex is male will be selected.
READ {.\Projects\Sample\Sample.prj}:Oswego SELECT Age > 30 SELECT Sex = "Male" LIST Age Sex
Example 7: A subset of the data contained in the Oswego data table is selected. Two SELECT commands have a cumulative effect making the two expressions equivalent to SELECT (Age > 30) AND (Age < 20). Only records where the age is greater than 30 and less than 20 are selected. Because these two conditions are mutually exclusive, the LIST command produces no output. A CANCEL SELECT command may be issued to clear the current selection criteria.
READ {.\Projects\Sample\Sample.prj}:Oswego SELECT Age > 30 SELECT Age < 20 LIST Age Sex