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: st: generating variable indicating presence/nonpresence in dataset by observation criteria
From 
 
Nick Cox <[email protected]> 
To 
 
"[email protected]" <[email protected]> 
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 <[email protected]> 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/