Working with a subset of data

v1.0
Other Commands How to...

select [logical expresion]

The select command allow the users to work with only a subset of data in the file in memory. The selected data set will be that matching the selection criteria specified under the "logical expresion".
If not variable names are indicated, select will anulate any previous selection statements, allowing the user to work with the complete dataset in memory.
The "logical expresion" can be as simple as SEX="FEMALE" or very complex. In the later case you must use AND and OR logical operator in order to get the apropiated combination to get the data set you want to work with.
Use of brakets()can modifie the way the expresion works, so be careful.
It is important to check the result of your "logical expresion" using the comands browse or list SELECT expressions are additive so that the two expressions:
SELECT AGE > 35
SELECT SEX = "F"
are equivalent to SELECT (AGE>35) AND (SEX = "F")
. SELECT NAME = “MAC” will select only “MAC”, but not “Mac”, etc.,because select is CASE SENSITIVE.
SELECT substr(NAME,1,3) =”MAC” will select all records where the first three letters in variable NAME are“MAC”, for example “MACDONALD”, etc.,

Output:

No specific output is generated

Notice: Be careful when you select on float variables (e.g: V1>3.1)
String variables are compared excluding trailing blanks


Examples and Hints
Select SEX="FEMALE"          (Select the subset of records where variable SEX is equal to FEMALE) 
Select AGE=31 (Select the subset of records where variable AGE is equal to 31)
Select SEX="MALE" and AGE=31 (Select the subset of records where variable SEX is equal to MALE and AGE is equal to 31)
SELECT ((age > 35) and (sex ="F")) or ((age > 40) and (sex ="M")) (Example using brakets and logical operators)
SELECT ILL=Y (Select all records with YES in the ILL field. Assuming ILL to be Yes/No field)
SELECT ILL=1 (Same that above. Remember: Yes=1 and No=0)
Select DOB > dmy(31,01,1959) (Select the subset of records where variable DOB is greater than 31/01/1959, assuming DOB is date variable)
Notice: dmy is a date function that specifies the values in brakets are a date (d=day, m=month y=year)

Related Commands:
Logical Operators
Date functions
String functions

Options:
No options in this command
Output variables:
No Output variables associated to this command
Output definition:
No set for this command
References:
Top