Patrick Sturgis
>thanks for your help. I'm running your second option for
> irregular suffixes
>and, although I don't seem to be getting error messages,
it isn't working.
>The first vector comprises variables:
>
>rpy204 rpy203 rpy199 rpy206 rpy210 rpy202 rpy014 rpy207
rpy209 rpy013 rpy201
>rpy200 rpy018 rpy016 rpy017
>
>the second vector comprises:
>
>_rpy204 _rpy203 _rpy199 _rpy206_rpy210 _rpy202 _rpy014
> _rpy207 _rpy209
>_rpy013 _rpy201 _rpy200 _rpy018 _ rpy016 _rpy017
>
>I have written the following code which produces the
> output as shown (note
>that I'm also including an if command as I only want to
copy over values
>conditional on the value of additional variable). The values of the
>variables in the first vector (or set) remain uncyhanged
> when I tab them.
>Any ideas?
>
>. foreach v of var rpy* {
>2. local new : subinstr local v "rpy" "_rpy"
>3. replace `new' = `v'
>4. } if show3 == 1
I don't believe you typed that and got success as the
trailing
if show3 == 1
is illegal.
foreach v of var rpy* {
replace _`v' = `v' if show3 == 1
}
should suffice here, except that Ernest's comment applies!
Nick
[email protected]
*
* 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/