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]

st: binary indicator for differing subsets of variables [SEC=UNCLASSIFIED]


From   "Fry, Jane" <Jane.Fry@pc.gov.au>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   st: binary indicator for differing subsets of variables [SEC=UNCLASSIFIED]
Date   Wed, 7 Sep 2011 14:04:50 +1000

Hi,

I'm a bit new to data manipulation using Stata and I have a query: I'd like to set up an indicator variable based on the sum of the values in a selection of other variables.

So, in my dataset I have variables on individual characteristics (like birth month and year) and a series of binary variables on labour force status (in/out) for consecutive months and years from Aug 2006 - Jan 2010:
LFS0806 LFS0906 LFS1006 ... LFS1109 LFS1209 LFS0110.

I would like to create a binary indicator variable to show whether or not an individual is in the labour force for 6 consecutive months --
e.g. LFS0107, ... , LFS0607=1.
The tricky bit is that the 6 month window for each individual ends in the month when they turn 25 -- i.e. the window shifts according to birthday.

I have set up an 'initial date' identifier variable (date1) that tells me when to begin the window and a 'final date' identifier variable (date2) that tells me when to end the window. So date1 and date2 are string variables of the form "MMYY".

e.g. for the first observation, date1="0107" and date2="0607", so LFS0107 ... LFS0607 are relevant here.
        for the next observation, date1="0906" and date2="0307", so LFS0906 ... LFS0307 are relevant here.

I think what I need to do is generate a new variable X=.  and then replace its values (for each individual) with a 1 or 0 if the sum of the relevant LFS variables is 6.
i.e. the sum of LFSMMYY to LFS(MM+6)YY = 6 (or each LFS is 1).

Trouble is, I don't know how to do it. I thought something like an egen X = rowtotal("LFS"+date1 - "LFS"+date2) might work but I was wrong! Is there anyone who can help?

Many thanks,
Jane.


____________________________________
Mrs. Jane Fry
Research Manager | Productivity Commission
12/530 Collins St, Melbourne
P: +61 3 9653 2125
E: Jane.Fry@pc.gov.au


Important Notice

This e-mail and attachments (if any) is intended for the original addressee only.
If you are not the intended recipient, any use or dissemination of this communication is prohibited.
Please advise the sender by return e-mail and delete this e-mail.

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