Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: How to genrate a variable containing some values of other variable


From   daniel klein <[email protected]>
To   [email protected]
Subject   Re: st: How to genrate a variable containing some values of other variable
Date   Thu, 5 May 2011 15:39:21 +0200

Problem seems solved but I just wanted to point out that there is no
need to loop over observations here.

/*---Example---*/

set obs 301
g old = _n

sort old // I know it is already sorted
g int new = 1 in 1
replace new = new[_n -1] + 5 in 2/`= 305/5'

/*---End---*/

Best
Daniel
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index