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

st: RE: rowmean within a loop

From   "Nick Cox" <>
To   <>
Subject   st: RE: rowmean within a loop
Date   Mon, 22 Jun 2009 12:02:37 +0100

The intent of the code you give is difficult to understand. It commits
you to generating 20000 new variables, s1-s10000 and u1-u10000, which I
doubt is what you really want. 

egen v`i' = rowmean(u`i') 

within a loop is just going to put the rowmean of one variable (that
variable, identically) in another variable, which is pointless. 

Do start again from the beginning: 

1. Explain your data. 

2. Explain your problem. 


Carlo Lazzaro

after typing 

qui forval i =1/10000  {
qui g double s`i' = Surv_Pos_IFI[`i']*(1-Monthly_Pr_Death_AML_MDS_Prob)
in 1
replace s`i' = s`i'[_n-1]*(1-Monthly_Pr_Death_AML_MDS_Prob) if s`i'==.
qui g double u`i' = s`i'*LYS

I would like to obtain a variable where I can store the rowmeans for all

I tried unsuccessfully to use egen v`i'=rowmean(u`i'), but this way I
(obviously, I would suppose) get v`i' for each u`i', and this not help
achievement of my research purpose.

*   For searches and help try:

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