Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: string manipulation


From   "Alex Ogan" <[email protected]>
To   <[email protected]>
Subject   st: RE: string manipulation
Date   Mon, 15 May 2006 12:06:11 -0400

There is a function reverse(s), so you can do something using
index(reverse(name)," ") combined with length(name).

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Rajesh
Tharyan
Sent: Monday, May 15, 2006 12:01 PM
To: [email protected]
Subject: st: string manipulation

Hi all,


I have a list of names in the following format

A K Nath
B G G goldfinger
G gomes
R raja micheal
Lothar

I need to get them in the following format

Nath A K
Goldfinger B G G 
Gomes G
Micheal R raja
Lothar

if they were all of the same length I could use the substr function to
do
this without any problem. With different lengths and different number of
forenames I am not sure 

But, This is what I have been thinking

1. If there is way to find out the position of the last space then I
could
use that info to split the names into forenames and surname
2. then concat them in the way I require
3. Since the number of forenames

Am I right? How do I get the position of the last space. I know Index
will
give me the location of the first instance of a character is there
something
similar location of the last instance? Or to start looking from the
back?

I am using Stata  8.2 

Thanks
rajesh

*
*   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/


This message is intended solely for the designated recipient(s). It may contain confidential or proprietary information and may be subject to confidentiality protections. If you are not a designated recipient, you may not review, copy, or distribute this message. If you receive this in error, please notify the sender by reply e-mail and delete this message. 

Arrowstreet Capital, L.P. is an Equal Opportunity Employer. 



*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index