Hi All,
I happen to have a question. Attached is the data table.
Basically, I would like to calculate the mean, stddev, and count based on "vol" columns by groups. So I first wrote the following scripts with the "Summarize()" function:
Summarize( vol_g = By( :group ),
vol_m_g0 = Mean( :vol_0),
vol_m_g1 = Mean( :vol_1),
vol_m_g2 = Mean( :vol_2),
vol_m_g3 = Mean( :vol_3),
vol_m_g4 = Mean( :vol_4),
vol_m_g5 = Mean( :vol_5),
vol_m_g6 = Mean( :vol_6),
vol_sd_g0 = stddev( :vol_0),
vol_sd_g1 = stddev( :vol_1),
vol_sd_g2 = stddev( :vol_2),
vol_sd_g3 = stddev( :vol_3),
vol_sd_g4 = stddev( :vol_4),
vol_sd_g5 = stddev( :vol_5),
vol_sd_g6 = stddev( :vol_6),
vol_n_g0 = Count( :vol_0),
vol_n_g1 = Count( :vol_1),
vol_n_g2 = Count( :vol_2),
vol_n_g3 = Count( :vol_3),
vol_n_g4 = Count( :vol_4),
vol_n_g5 = Count( :vol_5),
vol_n_g6 = Count( :vol_6)
);
But it is too lengthy, so I would like to use the "for" loop below instead:
For (i=0, i<=6, i++,
Summarize( vol_g = By( :group ),
Eval(Parse(Eval Insert ("vol_m_g^i^ = Mean(:vol_^i^)"))),
Eval(Parse(Eval Insert ("volsd_g^i^ = Stddev(:vol_^i^)"))),
Eval(Parse(Eval Insert ("vol_n_g^i^ = Count(:vol_^i^)")))
)
);
But this "for loop" version does not work. How could I revise it to make it work?
Thanks a lot!!