[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: Re: RE: manipulating string variables
One caveat about using the functions subinstr() and index() or strpos() is
that they will truncate strings longer than 244 characters and potentially
produce incorrect results. You should look at similar macro extended
functions -- subinstr and word come to mind -- check out -help
extended_fcn-. You may also find the macro extended list functions quite
useful as they will compare and subtract and manipulate long string lists
quite easily -- see -help macrolists-.
[mailto:firstname.lastname@example.org] On Behalf Of Jean Eid
Sent: Friday, July 21, 2006 10:22 AM
Subject: st: manipulating string variables
I have been trying to do the following with no luck (This is a
simplification rather than exact procedure needed)
Suppose I declare a global variable
global myglobal "hello world, how are you today"
now what I want to do is the following:
a) see whether the string text today exist in $myglobal
b) replace "today" by "tomorrow"
c) instead of "are" I need to change the "a" to "b" let's say.
I know this does not make sense to you right now but I have all these
regressions defined as global variables and need to manipulate them.
Can this be done in Stata?
I have checked strmatch and the likes but am not able to work it. I am
looking for something like grep, sub and the likes in Linux.
If you know how to do this Please provide a workable example.
* For searches and help try: