Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: Re: breaking strings


From   Nick Winter <nw53@cornell.edu>
To   statalist@hsphsun2.harvard.edu
Subject   RE: st: RE: Re: breaking strings
Date   Thu, 29 Sep 2005 12:39:38 -0400

Ooops.  That's the problem with not actually testing a proposed solution!

--NW


At 11:47 AM 9/29/2005, you wrote:
Nick,

Thanks for the tip.  I was just about to use Dev's suggestion and was
realizing how lengthy that could have become.  There was one change I made
to your code, and I thought I should note it for the record here:

You wrote:
        replace myvar = subinstr(myvar,",","")
        replace myvar = subinstr(myvar,".","")
But this produced a syntax error.

It should be:
        replace myvar = subinstr(myvar,",","", .)
        replace myvar = subinstr(myvar,".","", .)
Where the "." at the end informs stata to replace ALL ocurrences of either
"," or "." within the string myvar.  See
http://www.stata.com/help.cgi?string+functions

Otherwise, it seems to work perfectly.  Thanks again.


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Winter
Sent: Thursday, September 29, 2005 11:37 AM
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: RE: Re: breaking strings

  replace myvar = subinstr(myvar,",","")
  replace myvar = subinstr(myvar,".","")

Then use -split-.

--NIck Winter

At 11:16 AM 9/29/2005, you wrote:
>Thanks, split seems to do the job.  However now I have some special
>cases to deal with.  Say I have a company name like:
>Medical Research, Inc.
>
>I want to split this into
>Medical
>Research
>Inc
>So that the "," and the "." are dropped.  I've tried combining -split-
>with the -ignore- option, but it doesn't seem to be doing anything as
>the comma and period remain in the split variables.  Anyone know how to
>take care of this?
>
>Thanks,
>Terra
>

________________________________________________________
Nicholas J. G. Winter                     607.255.8819 t
Assistant Professor                       607.255.4530 f
Department of Government              nw53@cornell.edu e
Cornell University        falcon.arts.cornell.edu/nw53 w
308 White Hall
Ithaca, NY 14853-4601


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


*
*   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/
________________________________________________________
Nicholas J. G. Winter 607.255.8819 t
Assistant Professor 607.255.4530 f
Department of Government nw53@cornell.edu e
Cornell University falcon.arts.cornell.edu/nw53 w
308 White Hall
Ithaca, NY 14853-4601

*
* 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index