Mike,
There are several ways to do this. One is to just take the first and last
words and put a space in between:
. gen firstlast = word(fullname, 1) + " " + word(fullname, 2)
David
--
David Radwin
Senior Research Associate
MPR Associates, Inc.
2150 Shattuck Ave., Suite 800
Berkeley, CA 94704
Phone: 510-849-4942
Fax: 510-849-0794
www.mprinc.com
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-
> statalist@hsphsun2.harvard.edu] On Behalf Of Michael Stewart
> Sent: Tuesday, February 26, 2013 10:08 AM
> To: statalist
> Subject: st: Need help with string observations
>
> Hi,
>
> Can you please help me with String function
> I have a list of patients and unfortunately some pts have their names
> recorded in various formats like James Edward ; James Edward H;
> James Edward J etc
> Is it possible to write a code where the funcition removes the last
> alphabet for the string if it is listed separately like
>
> James Edward H--> James Edward
>
>
> --
> Thank you ,
> Yours Sincerely,
> Mike.
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/