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" <[email protected]>
To   <[email protected]>
Subject   st: RE: Least to variable continues
Date   Wed, 29 Nov 2006 09:34:16 +0100

--- [email protected] 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, 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 -------------------


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


*   For searches and help try:

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