Statalist


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

st: Re: how to add 23 in each row of a variable


From   Martin Weiss <[email protected]>
To   <[email protected]>
Subject   st: Re: how to add 23 in each row of a variable
Date   Mon, 15 Sep 2008 20:05:26 +0200

-replace number=number+23-

is the easiest solution. -replace- operates on the "vector" of observations for "number". If you are desperate for the -while- loop, make sure you step up the index, e.g. add -loc ++i - as the last statement before the closing brace...


HTH
Martin
_______________________
----- Original Message ----- From: "Fabian Brenner" <[email protected]>
To: <[email protected]>
Sent: Monday, September 15, 2008 7:59 PM
Subject: st: how to add 23 in each row of a variable



Hello,

how can I tell Stata to add 23 in each row of a variable in the dataset?

I do not know what I am doing wrong because it does not work like this:

local i=1
while `i'<_N {
2. replace number[i]= number[`i'] + 23
3. }

Thanks for your help.
Fabian

P.S. Thanks a lot to Neil for the help.



--
GMX Kostenlose Spiele: Einfach online spielen und Spa� haben mit Pastry Passion!
http://games.entertainment.gmx.net/de/entertainment/games/free/puzzle/6169196
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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