Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: AW: st: AW: Generating a dropout dummy variable?


From   Ignacio Martinez <[email protected]>
To   [email protected]
Subject   Re: AW: st: AW: Generating a dropout dummy variable?
Date   Sun, 27 Jun 2010 13:53:30 -0400

Thanks
Now i understand better.

I think I explain my self wrong the first time so the code is not doing
exactly what I need.

My data goes from 2000 to 2008. So is possible that a student enroll in
any year between 2000 and 2008. If I'm understanding the code right I
should change the first line to:
bys id: egen myvar=total(inlist(year,2000,2008))

Is this right?

But now I'm not sure how should I change the second line.

The problem is that some student were enroll for the first time in 2000
some others in 2001, 2002, etc.

So the code should do something like: when is the first time I see the
student. Do I see him after the first time. Was he graduated the last
time i saw him. Or something like that

Thanks a lot for your help.

-Ignacio


On Sun, 2010-06-27 at 19:38 +0200, Martin Weiss wrote:
> <> 
> 
> " About your code... I'm kind of lost on how you create the dropout
> indicator. Could you explain a little that piece of code?"
> 
> 
> 
> 
> 
> *************
> //get "dropout" indicator
> 
> //Do I see "id" in 2000 and 2001?
> bys id: egen myvar=total(inlist(year,2000,2001))
> 
> //How many times did I see "id" between 2002 and 2006?
> bys id: egen myvar2=total(inrange(year,2002,2006))
> 
> //dropout is 1 if I saw "id" in 2000 and 2001
> //and did not see him again afterwards
> //and, in 2001, his "graduated" was not 1
> bys id: gen dropout=((myvar==2)*(myvar2==0))& /* 
> */ ((graduated!=1)*(year==2001))
> *************
> 
> 
> See this thread for the tricks re "conditions": http://www.stata.com/statalist/archive/2010-06/msg00985.html
> 
> 
> 
> HTH
> Martin
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: [email protected] [mailto:[email protected]] Im Auftrag von Ignacio Martinez
> Gesendet: Sonntag, 27. Juni 2010 19:33
> An: [email protected]
> Betreff: Re: st: AW: Generating a dropout dummy variable?
> 
> About the second part:
> What I was trying to say is that if i see a student in the year 2000 and
> i don't see him in 2001 because he is taking a break but in the year
> 2005 he is back in my sample I don't want to mark him as drop out but I
> want to generate a variable that says that he took a 4 year break.
> 
> About your code... I'm kind of lost on how you create the dropout
> indicator. Could you explain a little that piece of code?
> 
> Thanks a lot
> 
> -Ignacio
> 
> 
> On Sun, 2010-06-27 at 19:01 +0200, Martin Weiss wrote:
> > <> 
> > 
> > The first part could be:
> > 
> > 
> > *************
> > 
> > //Create data
> > clear*
> > set obs 1000
> > set seed 43550
> > 
> > //id
> > gen int id=_n
> > 
> > //expand to # of time periods
> > expand 7
> > 
> > bys id: gen int year=_n+1999
> > gen byte graduated=  /* 
> > */ cond(runiform()<0.3 & year==2001,1,0) 
> > 
> > drop if runiform()<.7
> > 
> > xtset id year
> > 
> > //get "dropout" indicator
> > bys id: egen myvar=total(inlist(year,2000,2001))
> > bys id: egen myvar2=total(inrange(year,2002,2006))
> > bys id: gen dropout=((myvar==2)*(myvar2==0))& /* 
> > */ ((graduated!=1)*(year==2001))
> > drop myvar*
> > 
> > //take a look
> > bys id: egen anydropout=max(dropout)
> > l if anydropout, sepby(id)
> > *************
> > 
> > 
> > I do not understand the second part. Why would dropout be 1 in 2000 if you saw the guy in 2000?
> > 
> > 
> > HTH
> > Martin
> > 
> > -----Ursprüngliche Nachricht-----
> > Von: [email protected] [mailto:[email protected]] Im Auftrag von Ignacio Martinez
> > Gesendet: Sonntag, 27. Juni 2010 15:54
> > An: [email protected]
> > Betreff: st: Generating a dropout dummy variable?
> > 
> > Hi,
> > 
> > 
> > My panel has the following variables: Year (from 2000 to 2008), ID,
> > Graduated (an indicator =1 if the student graduated that year) . 
> > 
> > I want to generate a dropout variable. If I see ID==1111 in year==2000
> > and 2001 but not after that and graduated !=1 in 2001 I want dropout==1
> > in 2001 . The only other detail is that if a see someone in 2000 and
> > then I see him again in 2006 with graduated=1 I don't want dropout =1 in
> > 2000 I want other variable that is break=5 (that student took 5 year of
> > break)
> > 
> > 
> > Thanks for the help
> > 
> > 
> > -Ignacio
> > 
> > 
> > *
> > *   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/
> > 
> > 
> > *
> > *   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/
> 
> 
> *
> *   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/
> 
> 
> *
> *   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/


*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index