Bookmark and Share

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

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

Re: st: to write _n in [./.] form

From   Nick cox <>
To   "" <>
Subject   Re: st: to write _n in [./.] form
Date   Sat, 26 Feb 2011 08:48:03 +0000

This sounds like a problem in spells. You might check out -tsspell- from SSC and/or my article in Stata Journal 7(2): 249-265 (2007) which is accessible to non-subscribers. They provide and explain machinery that might help.

On 25 Feb 2011, at 18:59, ajjee <> wrote:

Dear All

I have to calculate a variable in this way

gen awc_4=1 if awc[_n]==1 & awc[_n+1]!=1 & awc[_n+2]!=1 & awc[_n+3]! =1 &

and on basis of the above variable, generate a new variable of average

gen rgg3avgf=( rgg[_n]+ rgg[_n+1]+ rgg[_n+2])/3 if  awc_4[_n-1]==1

Is there a way to write the above commands in short form ( like, _n/ _n+3) ....
*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index