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 on April 23, and its replacement, statalist.org is already up and running.


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

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


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

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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index