Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: AW: st: Eliminating patterns from Panel Data


From   Maarten buis <[email protected]>
To   [email protected]
Subject   RE: AW: st: Eliminating patterns from Panel Data
Date   Sun, 20 Jan 2008 20:06:57 +0000 (GMT)

And here is the final update of -mkbalanced- (this also illustrates
that writing software is an itterative process, especially for a sloppy
person like me...)

*--------- begin mkbalanced.ado------------------
*! version 1.0.3 MLB 20Jan2008
program define mkbalanced, sortpreserve
        version 9.1
	syntax, GENerate(name)
	confirm new var `generate'
	capture xtset
	if _rc == 459 {
		di as err ///
		"panel variable not set, use -xtset varname ...-"
		exit 459
	}
	if "`r(timevar)'" == "" {
		di as err ///
		"must specify timevar; use xtset"
		exit 459
	}
	local panelvar "`r(panelvar)'"
	local timevar "`r(timevar)'"

	tempvar touse nvals
	gen byte `touse' = !missing(`timevar')

	qui levelsof `timevar'
	local t : word count `r(levels)'
	bys `panelvar' `timevar' `touse' : ///
          gen long `nvals' = _n == 1 if `touse'
	bys `panelvar' `touse' : ///
	    replace `nvals' = sum(`nvals') if `touse'
	bys `panelvar' `touse' : ///
	    gen byte `generate' = `nvals'[_N]== `t'
        label variable `generate' ///
        "whether or not a unit is completely observed"
end
*--------- end mkbalanced.ado------------------


-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      __________________________________________________________
Sent from Yahoo! Mail - a smarter inbox http://uk.mail.yahoo.com

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index