[EpiData-list] Re: selecting on string variables

epidata-list at lists.umanitoba.ca epidata-list at lists.umanitoba.ca
Wed May 25 09:59:11 CDT 2005


Why is this necessary?  I see "LION",  upper case and delineated with "
".
Thanks, Kelly

-----Original Message-----
From: epidata-list at lists.umanitoba.ca
[mailto:epidata-list at lists.umanitoba.ca] 
Sent: Sunday, May 01, 2005 2:16 PM
To: epidata-list at lists.umanitoba.ca
Subject: [EpiData-list] Re: selecting on string variables


>    1. How to select "string variables" in Epidata Analysis	?
>   select outcome="death"
An example should clarify:
Try this:
generate 3          // make 3 artificial records
gen integer id = recnumber          // create id variable
define animal _________             // make a string variable
* add value to the variable:
if recnumber = 3 then animal = "monkey"
if recnumber = 1 then animal = lower("LION")
if recnumber = 2 then animal = "LION"
. list
ID            ANIMAL     
1             lion       
2             LION       
3             MONKEY    
* so we see that we have three values for the variable animal.

* and we have two variables:
. var
Name	Type	Length	Decimals
ID	Integer	12	0	 	 		 
ANIMAL	String	9	0	%s9	 		 

* now we try various selects:

select if animal = "LION"
count
No records available
select                   //  to
select if upper(animal) = "LION"
count
No records available
select
select if upper(trim(animal)) = "LION"
count
Count : 2

The essense is therefore that to do a select on a string variable, you 
have to use as well sometimes the function upper() and the function 
trim() to get a proper selection.


regards

Jens Lauritsen
Initiator of EpiData
Coordinator EpiData Association



More information about the EpiData-list mailing list