Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: egen anycount


From   daniel klein <klein.daniel.81@googlemail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: egen anycount
Date   Thu, 19 May 2011 00:35:49 +0200

I am not aware of a command, but it should not be hard changing the
existing -anycount-. Here's an ad hoc step-by-step

1. locate -anycount- and open it in the do-file editor

. findfile _ganycount.ado
. doedit "`r(fn)'"

2. change the file (don't save the changes yet)

2.1 change line 2 form

"program define _ganycount"
to
"program define _ganycount2"

2.2 change line 7 from

"[...] , Values(numlist int) /*"
to
"[...] ,Values(numlist) /*"

2.3 change line 26 from

"*/ if ``i'' == `nj' & `touse'"
to
*/ if ``i'' == float(`nj') & `touse'

3. save the file as _ganycount2.ado to your "personal" folder
(to locate type: -di c(sysdir_personal)-) or alternatively to your
"plus/_/" folder (locate: -di c(sysdir_personal)-)

4. -discard- Stata

5. use your -anycount2- function
. egen somevar = anycount2(varlist), values(1.2 0.8 1.5)

Best
Daniel
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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   |   Site index