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

st: AW: rowmean within a loop

From   "Martin Weiss" <>
To   <>
Subject   st: AW: rowmean within a loop
Date   Mon, 22 Jun 2009 12:52:48 +0200


-egen, rowmean()- takes a -varlist- as argument, but you are passing a
-varname- to it. The whole idea is that you get the mean across columns, but
you are asking for the mean of one column... If you could give a verbal
description of a simplified version of your prob, that would be helpful... I
could see you using -egen v=rowmean(u1 - u10000), for instance...

Also note that -generate- does not respect your -in- qualifier, or rather is
does, but still fills the rest of the column with missings...


-----Ursprüngliche Nachricht-----
[] Im Auftrag von Carlo Lazzaro
Gesendet: Montag, 22. Juni 2009 12:45
Betreff: st: rowmean within a loop

Dear Statalisters,
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 the

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 the
achievement of my research purpose.

Thanks a lot for your kindness and for your time.

Kind Regards,

*   For searches and help try:

*   For searches and help try:

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