Page 1 of 1

calculating mean

Posted: Tue Feb 28, 2017 7:24 am
by tony
Hi, there
surppose there is a variable, cigs, which show the number of one somke per day, 0 means no smoking. And I want to calculate the mean of
those take cigarrets. How to do that?

Thank you, all

Re: calculating mean

Posted: Tue Feb 28, 2017 8:23 am
by startz
Look at the help system for @mean

Re: calculating mean

Posted: Thu Mar 02, 2017 6:25 am
by tony
Look at the help system for @mean
I read the help, but I have no idea about this, could you show me the right way.
Thank you.

Re: calculating mean

Posted: Thu Mar 02, 2017 6:55 am
by startz
series y =@mean(cigs)

Re: calculating mean

Posted: Sat Mar 04, 2017 8:56 pm
by tony
No, I mean y=@mean(cigs, in which cigs not equal to 0).
Say there are 50 observations in which 30 observations equal 0.
I just want to calculate the mean of the rest 20, and how to do this using a command function.
Thank you.

Re: calculating mean

Posted: Sat Mar 04, 2017 9:00 pm
by startz
smpl if cigs>0
series y=@mean(cigs)

or set the smpl and then open cigs and view stats

Re: calculating mean

Posted: Sat Mar 04, 2017 10:26 pm
by tony
Thanks a lot!