Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
ChrisAnsen <lakridstina@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: copy part of a string |

Date |
Sat, 15 Oct 2011 18:21:39 +0200 |

Dear all I run into an issue with STATA today. I have a datalist with over 1000 string variables in the following type 1. "M200B + M201 + B001" 2. "M200B + M201" 3. "M200 + M300" 4. ... 5. and so on. Now I want to read the first part of the string, example: "M200B" and insert it in a new column and then read the second and the third part of it if applicable. I am doing this by using the command:

Now this gets my what I want, having what is before the + sign. Now I want what is after the + sign and I am doing it be using the following command:

This gives the value if it is in the form of "M200B" and by adding an OR and transforming it to:

I am getting an error that it is outside range, or something similar. Can someone tell me where I am making the mistake, or if there is an other way to do it? I though of using a dummy variable as a mid-step but I do not like the idea because later when I have six variable "M2008 + .......+M20" it will be messy, and it should be durable on the "correct" way. Also I know how to make it more tide up by using [0-9] for example so please do not mention any of those advices :) Thank you all in advance Best regards Christina Christiansen, DK * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: copy part of a string***From:*"Dimitriy V. Masterov" <dvmaster@gmail.com>

**References**:**st: Post estimation power estimations.***From:*Lars Folkestad <lfolkestad@health.sdu.dk>

**RE: st: Post estimation power estimations.***From:*Cameron McIntosh <cnm100@hotmail.com>

- Prev by Date:
**Re: st: RE: ivreg2 bandwidth** - Next by Date:
**Re: st: Stata 11 under Gnome 3** - Previous by thread:
**RE: st: Post estimation power estimations.** - Next by thread:
**Re: st: copy part of a string** - Index(es):