Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | daniel klein <klein.daniel.81@googlemail.com> |
To | statalist@hsphsun2.harvard.edu |
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/