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]

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


From   ajjee <[email protected]>
To   [email protected]
Subject   st: to write _n in [./.] form
Date   Fri, 25 Feb 2011 10:59:32 -0800 (PST)

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 & 
awc[_n+4]!=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) as
for other variables I've to include more terms in calculation of awc_3y and
also for higher term in averages.

Thanks in advance

ajjee
-- 
View this message in context: http://statalist.1588530.n2.nabble.com/to-write-n-in-form-tp6065663p6065663.html
Sent from the Statalist mailing list archive at Nabble.com.
*
*   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