Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: How do I split a string variable without spaces by capital letters?
From
Andrew Dickens <[email protected]>
To
[email protected]
Subject
st: How do I split a string variable without spaces by capital letters?
Date
Mon, 19 Aug 2013 10:06:05 -0400
Hi all,
I'm currently running Stata 10, and I'm having a problem splitting a
string variable by capital letters. Elena Vidal posted something under
a similar title,
http://www.stata.com/statalist/archive/2011-11/msg01195.html, but the
her problem is somewhat different than mine and I was unable to
troubleshoot.
An example of my data is as follows:
clear all
inp str13(v1)
"TestOne"
"ThisistestTwo"
"AndThree"
end
The problem is the capital letter I wish to split each cell by is not
consistently placed.
I tried splitting using this code:
split v1, p(upper(a-z))
or
split v1, p(upper(.))
but this just generates an identical variable to v1.
What I would like to do is create two new variables, so the first
observation of my example would have "Test" in the first new variable
and "One" in the second new variable. Suggestions would be greatly
appreciated.
Thank you for your consideration.
Andrew
*
* 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/