Statalist The Stata Listserver


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

st: separating string variable into components


From   "Radu Ban" <[email protected]>
To   [email protected]
Subject   st: separating string variable into components
Date   Sun, 13 Aug 2006 16:08:19 -0400

Dear Listers,

I have a string variable that looks like this:

mystring
  (1 2 3) (1 2 2)  (7 8 9)    (1 3 4)
(2 3 4)    (1 2 3) (10 11 12)

etc. The numbers inside the brackets are made up. The problem is that
the number of spaces between brackets is not constant. Also the number
of brackets is not constant across observations. I want to split this
variable so that each bracket is contained in its own variable, i.e.

split1   split2    split3         split4
(1 2 3)  (1 2 2)  (7 8 9)        (1 3 4)
(2 3 4)  (1 2 3)  (10 11 12)   <blank>

I've tried the -split- command, with various numbers of spaces as the
parse character, but that doesn't work, i.e. it doesn't split if i
specify too many blanks, or it creates blank observations if i specify
too few blanks.

Any suggestions are appreciated.

Thanks,
Radu Ban
*
*   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