Statalist


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

st: subinstr does not replace but repeats


From   Carlos Eduardo Hernandez Castillo <cehc84@hotmail.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: subinstr does not replace but repeats
Date   Tue, 6 May 2008 21:01:23 -0500

Hello.


I am trying to use subinstr with a long string. However, I am not getting what I think I should be getting:


display subinstr("ide011 ide010 ide001 per001 per004 per008 edu007 edu004 ftr014 ftr014v ftr014a ftr020 mig006 mig002 mig005 mig001 ocu009 ocu008 ocu007 ocu006 ocu003 "," ","_20051 ",.)

ide011_20051 ide010_20051 ide001_20051 per001_20051 per004_20051 per008_20051 edu007_20051 edu00
> 4_20051 ftr014_20051 ftr014v_20051 ftr014a_20051 ftr020_20051 mig006_20051 mig002_20051 mig005
> _20051 mig001 ocu009ocu009 ocu008 ocu007 ocu006 ocu003


Notice that it works well UNTIL mig005. It does not work afterwards. It even repeats ocu009. 

I am working with Stata SE 10 for Windows. I think that it may have to do with the length of the string. I have thought about using tokenize and then rebuild the modified string. However, I usually work with long strings and string functions, so doing this everytime would make my programs long and hard to read. Could you please help me to realize how can I solve my problem in an efficient way? 

Thanks in advance.

Carlos Eduardo Hernández Castillo
Colombia



_________________________________________________________________
Explore the seven wonders of the world
http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE
*
*   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