[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: RE: St: replace in

From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: St: replace in
Date   Fri, 24 Oct 2008 15:30:02 +0100

To elaborate on Martin's comment: 

This is nothing to do with -for-. At Eric's request, I won't lecture him
against using -for-. I'll just explain to everyone else that -for- is
outdated, slow, and may bite you, just like a bad-tempered dog in
retirement. Still, you may have good feelings for that dog, remembering
happier days. 

Eric's problems would arise with e.g. 

replace lbmlifexint1993[_40] = lbmlifexint1993[_41] if
lbmlifexint1993[_41] == .

The underscores don't belong here. (Perhaps Eric is thinking somehow of

replace lbmlifexint1993[40] = lbmlifexint1993[41] if lbmlifexint1993[41]
== .

Now see things from Stata's viewpoint. The syntax for -replace- is 

replace oldvar =exp [if] [in]

setting aside an option not relevant here. 

So nothing can go before the = sign except the name 

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Martin Weiss
Sent: 23 October 2008 23:03
To: [email protected]
Subject: st: RE: St: replace in

Try this:

sysuse auto, clear
list mpg trunk in 23/24
replace mpg=2 in 23
replace mpg=trunk in 24
list mpg trunk in 23/24

Do not try this:

replace mpg[23]=2


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Eric Uslaner
Sent: Thursday, October 23, 2008 11:58 PM
To: [email protected]
Subject: st: St: replace in


I have some historical data with different rows for countries such as
Czech Republic and the old Czechoslovakia.  I'd like to replace the
values for the Czech Republic with those for the former Czechoslovakia
I know that there is a Slovakia--but I'll handle that separately).  The
for the Czech Republic is 40 and for Czechoslovakia is 41.  So I tried

for var bmginiint1820-lbmlifexint1993: replace X[_40]=X[_41] if

(and please don't lecture me on using the "for" command).  But I keep
getting the error message:

weights not allowed

Can I do this?  In the past I have just cut and pasted the data, but I
a large number of variables and this could get awkward.  Any help would
appreciated.  Thanks.

Ric Uslaner

*   For searches and help try:

*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index