Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Weights vs subscripts

From   "Fan, Shihe" <>
To   <>
Subject   st: Weights vs subscripts
Date   Tue, 3 Oct 2006 13:57:29 -0600


Could any one explain to me why it is OK to write the code in the
following way

gen y=0

foreach i of varlist x {
replace y=y[`i'-1]+ z[`i'] 

but not OK in this way

replace y[`i']=y[`i'-1] +z[`i']

the program always treat the [`i'] on the left side as weights, instead
of subscripts

Thank you,

Shihe Fan
Office of the MOH
Public Health Division
Suite 300, 10216 - 124 Street
Edmonton AB T5N 4A3		
Phone:(780) 413-7742
Fax: 	(780) 413-7950

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index