Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: make a program byable


From   "Katsuhide Isa" <CQB01114@nifty.ne.jp>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: make a program byable
Date   Mon, 24 Jun 2002 02:05:05 +0900

Dear Stata listers:

Recently I wrote the following simple program
titled 'coefvar.ado' for the purpose of calculating
coefficients of variation.

----------coefvar.ado----------
program define coefvar, rclass byable(recall)
 version 7
 qui summ `1', det
 local coefvar = r(mean)/r(sd)
 di in green _col(8) `coefvar'
end
----------coefvar.ado----------

But somehow it doesn't work as expected.
More specifically, when typing like

'bys year : coefvar basepay'

using a data set containing multiple panels, following
results:are shown on the screen:

____________________________________________________________________________
___
-> year = 1989
       3.7137332

____________________________________________________________________________
___
-> year = 1990
       3.7137332

____________________________________________________________________________
___
-> year = 1991
       3.7137332

____________________________________________________________________________
___
-> year = 1992
       3.7137332

____________________________________________________________________________
___
-> year = 1993
....

and so on. Namely, they are all the same for
each year when they should vary from year
to year.
I guess something is wrong or missing with this
program, but I'm sorry I can't fix it.

Is there any better idea? Any suggestions welcome.
Thanks in advance.

K.I.




*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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