Statalist The Stata Listserver


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

st: RE: Least to variable continues


From   "Maarten Buis" <M.Buis@fsw.vu.nl>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Least to variable continues
Date   Wed, 29 Nov 2006 09:34:16 +0100

--- ncdcta00@uniroma2.it wrote:
> I have a panel when I take the female that worked in at least two years

I assume you have or can make a variable that identifies whether a person 
worked in a year is coded 0 if she did not work and 1 if she did. In that
case, if we could make a new variable that contains the sum of the work 
variable for each person separately than we would know how many years each 
person worked and then it would be straight forward to select those that 
worked more than 2 years and are female. This can be done by combining 
-egen varname = total(work)- with the -by- prefix, see the example below 
which uses number of years in union instead of work and black instead of 
female. Also see -help egen- and -help by-.

*------------ begin example ------------------
use http://www.stata-press.com/data/r9/union, clear
list idcode year union black if idcode >=2 & idcode <=4
/*persons 2 and 4 were more then two waves in the union
  and person 3 was not but person 4 wasn't black, so only
  person 2 should be selected */

bys idcode: egen tunion = total(union) 
gen morethan2 = tunion >= 2 & black == 1
list idcode year union black tunion morethan2 if idcode >=2 & idcode <=4
*------------- end example -------------------

HTH,
Maarten

-----------------------------------------
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/
-----------------------------------------

 

*
*   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