Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

[no subject]



1. If one person is named, that is the doctor. 
(???) 

2. If one person is labelled "DR" or "DT", 
that is the doctor. 

3. If one person is labelled "NURSE", the 
other person is the doctor. 

I'd do this. From other postings it seems that
you are on Stata 7, but have access to an 
unofficial version of -split-. 

gen str1 doctor = "" 
split staff, parse(,) 
replace doctor = staff1 if index(staff1, "DR ") 
replace doctor = staff2 if index(staff2, "DR ") 
replace doctor = staff1 if index(staff1, "DT ") 
replace doctor = staff2 if index(staff2, "DR ") 
replace doctor = staff1 if index(staff2, "NURSE") 
replace doctor = staff2 if index(staff1, "NURSE") 
replace doctor = staff1 if trim(staff2) == "" 

Note the search for "DR " etc. This is to avoid 
false positives like finding 

"JUDGE DREDD NURSE" 

or 

"DEIRDRE MCCULLAGH-NELDER NURSE" 

Note also that results could be sensitive 
to order of the -replace- statements above. 

But there could be difficulties. The following
spring to mind, and no doubt there could be others. 

a. Doctors with the name "NURSE", e.g. DR NAOMI
NURSE. 

b. Any nurses whose names end with "DR" or "DT"?

A simple way of identifying problems is like 
this. 

gen byte problem = 0  
replace problem = 
	index(staff1, "NURSE") & index(staff2, "NURSE") 
replace problem = 
	index(staff1, "NURSE") & index(staff1, "DR ") 
replace problem = 
	index(staff2, "NURSE") & index(staff2, "DR ") 
replace problem = 
	index(staff1, "NURSE") & index(staff1, "DT ") 
replace problem = 
	index(staff2, "NURSE") & index(staff2, "DT ") 
... 
list if problem 

Nick 
n.j.cox@durham.ac.uk 

Paul O'Brien
 
> I want to create a new variable DOCTOR containing the names of the 
> doctors from the variable 'STAFF'. The doctor's names appear in 
> different order. Around 40,000 records.
> 
> I have tried
> . gen str40 dr= staff
> .split staff, parse(DR )
> 
> ... but there are some errors in the results
> 
> I'd appreciate help.
> 
> STAFF
> DR RAMA SETIA
> DR RAMA SETIA,HELEN BROSNAN NURSE
> DR S.K. PATTANI
> DR S.K. PATTANI,CELIA GAGE
> DR S.K. PATTANI,DAPHNE BOULTER
> DR S.K. PATTANI,GRACE BARANGO NURSE
> DR SABINA HUSSAIN
> DR SABINA HUSSAIN,GRACE HICKEN NURSE
> DT GITA HALDER
> DT GITA HALDER,DAPHNE BOULTER
> DR JOGARAJAH
> DR JOGARAJAH,CELIA GAGE
> DR JOGARAJAH,GRACE HICKEN NURSE
> DR JOGARAJAH,JENNY CHANDLER NURSE
> EDWINA JAMES
> EILEEN SHIWLOCHAN
> GEORGINA SIMEI
> GRACE BARANGO NURSE,CELIA GAGE
> GRACE BARANGO NURSE,DR ASSANI
> GRACE BARANGO NURSE,DR D ASARE-BROWN
> GRACE BARANGO NURSE,DR FLORENCE KALIKWAN
> GRACE BARANGO NURSE,DR P.K.PATTANI
> GRACE BARANGO NURSE,DR S.K. PATTANI

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index