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   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: how to add 23 in each row of a variable
Date   Mon, 15 Sep 2008 19:04:47 +0100

Absolutely no loop is needed here. 

. replace number = number + 23 

Nick 
n.j.cox@durham.ac.uk 

P.S. Why didn't it work? One reason is that you wrote 

replace number[i] = 

which is illegal, quite apart from other problems. 

P.P.S. Stata terminology is observations, not rows.

Fabian Brenner

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. }


*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index