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]

RE: st: generating variable indicating presence/nonpresence in dataset by observation criteria


From   Erik Aadland <erikaadland@hotmail.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: generating variable indicating presence/nonpresence in dataset by observation criteria
Date   Fri, 15 Jul 2011 09:33:24 +0000

Thank you, Nick.
 
"tsfill, full" did the trick.
 
Regards,
 
Erik.


----------------------------------------
> From: njcoxstata@gmail.com
> To: statalist@hsphsun2.harvard.edu
> Subject: Re: st: generating variable indicating presence/nonpresence in dataset by observation criteria
> Date: Fri, 15 Jul 2011 10:02:34 +0100
>
> Look at -tsset- and then -tsfill-.
>
> Nick
>
>
> On 15 Jul 2011, at 09:54, Erik Aadland <erikaadland@hotmail.com> wrote:
>
> > Dear statalist.
> >
> > I have an unbalanced panel dataset in which different actors
> > (agency_id) are present with a project (st_project_id) in the
> > dataset in some months (yearmonth) but not in other months. I would
> > like to estimate the likelihood that each actor (agency_id) is
> > present with a project (st_project_id) in yearmonth. Some actors
> > enter more projects, and are consequently more likely to be present
> > in yearmonths with projects.
> >
> > To do this, I am therefore trying to generate a variable for each
> > agency_id that takes on a value of 1 if the agency_id is present in
> > the dataset a given month, and 0 if the actor is not. Is this
> > possible? Or are there other ways for me to accomplish my objective?
> >
> > Here is an example dataset structure:
> >
> > yearmonth agency_id st_project_id
> > 1 1 1
> > 1 2 2
> > 1 4 3
> > 2 3 4
> > 2 5 5
> > 2 1 6
> >
> > In this example, agency_id 3 and 5 would get a value of 0 for
> > yearmonth 1 and a value of 1 for yearmonth 2. Agency_id 1 would get
> > a value of 1 for both yearmonths. Agency_id 2 would have a value of
> > 1 for yearmonth 1 and 0 for yearmonth 2, and so on.
> >
> > Any suggestions on this would be very much appreciated.
> >
> > Kind regards, Erik.
> > *
> > * 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index