Retreiving a string
Epidata friends,
I just spend almost the whole day trying to fix some typing errors. Nothing more than usual before starting some analysis. However It came to my attention that having just one key field maybe a lot misleading.
Lets say that there a key id field called number in qes.
v1 number #########
if the one who is typing types the worng number lets say 231022009 instead of 221022009 later this error may cause a lot of confusion and lead to other errors. The point is that this particular sort of error is hard to find and locate because this is the one field by which we should locate the record (the link to the CRF).
Looking for the record by other fields is very fustrating unless the record has some very unusual data, such as age 99. How many records I would have with age 99?? Most likeli very few.
One field that very often hleps is the patient intials, although it has very few letters, very unlikeli there is more than 3 or 4 in every thousand records with the same initials.
Therefore I ask to you guys if there is a way in the chk file to retrieve from the name the initials of the full name.
v1 number #########
v2 name: <A >
v3 initials: <A >
The objetictive is:
v2 name: JENS LAURISTEN
v3 initials: JL
v2 name: PEDRO EMMANUEL AMERICANO DO BRASIL
v3 initials PEADB
Telling the typer to type this is an option, but Is it possible stick this magic in the chk file? I looked in the string functions from Epidata documentation but didnt find anything that could make a way around!
Best regards?
Abraço forte e que a força esteja com você, Pedro Emmanuel
It is possible to extract the initials from a name field. It requires the repeated search for blanks in the field NAME and then adding the next letter to the string of initials. Here is my solution, which checks for up to six initials and will not allow a leading blank nor double blanks within name (as either would put a blank into the initials). Of course, this does not help you if the initials are not correct (e.g. if someone entered your name as PEDROE MMANUEL AMERICANO DO BRASIL ).
The SOUNDEX function might be more useful if spelling is likely to be a problem.
Jamie
For the simple .QES file:
name <A > inits <A > Up to six initials nextvar #
here is the .CHK file:
before file define initpos ## global define tempname _________________________ global end
NAME AFTER ENTRY tempname = name inits = copy(tempname,1,1) if inits = . then help "Cannot have name starting with blank" goto name exit endif initpos = pos(" ",tempname) if initpos > 0 then help "Cannot have name with double blanks" goto name exit endif
initpos = pos(" ",tempname) if initpos = 0 then goto nextvar exit endif tempname = copy(tempname,initpos+1,100) inits = inits + copy(tempname,1,1)
initpos = pos(" ",tempname) if initpos = 0 then goto nextvar exit endif tempname = copy(tempname,initpos+1,100) inits = inits + copy(tempname,1,1)
initpos = pos(" ",tempname) if initpos = 0 then goto nextvar exit endif tempname = copy(tempname,initpos+1,100) inits = inits + copy(tempname,1,1)
initpos = pos(" ",tempname) if initpos = 0 then goto nextvar exit endif tempname = copy(tempname,initpos+1,100) inits = inits + copy(tempname,1,1)
initpos = pos(" ",tempname) if initpos = 0 then goto nextvar exit endif tempname = copy(tempname,initpos+1,100) inits = inits + copy(tempname,1,1)
initpos = pos(" ",tempname) if initpos = 0 then goto nextvar exit endif tempname = copy(tempname,initpos+1,100) inits = inits + copy(tempname,1,1)
END END
Pedro wrote:
Therefore I ask to you guys if there is a way in the chk file to retrieve from the name the initials of the full name.
v1 number #########
v2 name:
<A >
v3 initials: <A >
The objective is:
v2 name: JENS LAURISTEN
v3 initials: JL
v2 name: PEDRO EMMANUEL AMERICANO DO BRASIL
v3 initials PEADB
participants (1)
-
epidata-list@lists.umanitoba.ca