Bookmark and Share

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: Splitting string variables "advanced"


From   "Seliger Florian" <seliger@kof.ethz.ch>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   st: Splitting string variables "advanced"
Date   Wed, 18 Jan 2012 14:05:52 +0000

Dear Statalist,

I want to split string variables with values such as:

EP1763200-A1 -- EP1530342-A2   ;  US2004199663-A1   HORVITZ E J (HORV-Individual);  APACIBLE J T (APAC-Individual)   HORVITZ E J,  APACIBLE J T;  US2004254998-A1   MICROSOFT CORP (MICT)   HORVITZ E J

 

At the end, there should be several variables and their values should look as follows:

 

Var1
EP1763200-A1 -- EP1530342-A2   

Var2
US2004199663-A1   HORVITZ E J (HORV-Individual);  APACIBLE J T (APAC-Individual)   HORVITZ E J,  APACIBLE J T

Var3
US2004254998-A1   MICROSOFT CORP (MICT)   HORVITZ E J

 

My problem is the following: I used 

split cp, p(" ; " "; ")

but in this case, Stata will also split Var2 because of the semicolon.

I'm searching for a way to tell Stata that it should keep the value of Var2 in one variable if there is a semicolon before a name.

Stata shall be asked to split the variable only if there is a number after the semicolon.

Alternatively, I would like to delete the confusing semicolon in a first step, then asking Stata to split the variable with split cp, p(" ; " "; ").



Kind regards,

Florian

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


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index