Hello statalisters,
I've been struggling with this for a while so I had to ask this on statalist.
I'm currently getting familiar with the program concept and I've done one myself. The purpose is to return the mean of a variable passed as an argument
The problem is that this program displays a value that is different from the mean of weight of the auto.dta.
How can I correct this?
===
My second problem is : I would like to design a program that returns to me a local (macro) that I can then store and use. I know that there is this s() command, but I don't how to use it.
Thank you for your kind help
Dusan
I've been struggling with this for a while so I had to ask this on statalist.
I'm currently getting familiar with the program concept and I've done one myself. The purpose is to return the mean of a variable passed as an argument
Code:
sysuse auto, clear program drop _all capture drop program prog1 program define prog1 version 13.0 syntax varname qui sum `varname' local moy=r(mean) dis `moy' end sum weight dis r(mean) prog1 weight
How can I correct this?
===
My second problem is : I would like to design a program that returns to me a local (macro) that I can then store and use. I know that there is this s() command, but I don't how to use it.
Code:
sysuse auto, clear program drop _all capture drop program prog1 program define prog1 version 13.0 syntax varname qui sum `varname' local moy=r(mean) *dis `moy' return local `moy' end prog1 weight local mu=s(local) // r(151) error
Dusan
Comment