Statalist The Stata Listserver

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

st: RE: string manipulation

From   "Alex Ogan" <>
To   <>
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-----
[] On Behalf Of Rajesh
Sent: Monday, May 15, 2006 12:01 PM
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

I need to get them in the following format

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

if they were all of the same length I could use the substr function to
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
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
give me the location of the first instance of a character is there
similar location of the last instance? Or to start looking from the

I am using Stata  8.2 


*   For searches and help try:

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:

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