Statalist The Stata Listserver


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

st: RE: Weights vs subscripts


From   "Alex Ogan" <[email protected]>
To   <[email protected]>
Subject   st: RE: Weights vs subscripts
Date   Tue, 3 Oct 2006 16:23:31 -0400

Somebody more knowledgeable will probably explain exactly why you can't
use subscripts on the left side like that.

But I can suggest a workaround:

replace y=y[`i'-1] +z[`i'] if _n==`i'
 
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Fan, Shihe
Sent: Tuesday, October 03, 2006 3:57 PM
To: [email protected]
Subject: st: Weights vs subscripts

Hi,

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
Epidemiologist
Office of the MOH
Public Health Division
Suite 300, 10216 - 124 Street
Edmonton AB T5N 4A3		
Phone:(780) 413-7742
Fax: 	(780) 413-7950		
[email protected]

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


This message is intended solely for the designated recipient(s). It may contain confidential or proprietary information and may be subject to confidentiality protections. If you are not a designated recipient, you may not review, copy, or distribute this message. If you receive this in error, please notify the sender by reply e-mail and delete this message. 

Arrowstreet Capital, L.P. is an Equal Opportunity Employer. 



*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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