Hi all, I have a question related to constructing a variable in panel.
I want to create a variable that captures the activeness of the organization.
I have a panel organization-year data where I have a variable that captures the # of events per year. Essentially my data looks like the following.
organization year #_events
1 1990 0
1 1991 0
1 1992 1
1 1993 2
1 1994 0
1 1995 0
1 1996 1
I want to construct a variable that captures the activeness of the organization. I want it to be coded as 1 if the org had at least one event in past n years including the current year. For example, if it is 3, the 'active' will equal to 1 starting from 1992 to 1996. However, if n=2, the active will equal to 1 from 1992 to 1994, and 0 for 1995, and then 1 for 1996 again.
I would think that I can use combination of by and sort but I have no clue how to do them. Please advice!
Many thanks in advance.
-S
I want to create a variable that captures the activeness of the organization.
I have a panel organization-year data where I have a variable that captures the # of events per year. Essentially my data looks like the following.
organization year #_events
1 1990 0
1 1991 0
1 1992 1
1 1993 2
1 1994 0
1 1995 0
1 1996 1
I want to construct a variable that captures the activeness of the organization. I want it to be coded as 1 if the org had at least one event in past n years including the current year. For example, if it is 3, the 'active' will equal to 1 starting from 1992 to 1996. However, if n=2, the active will equal to 1 from 1992 to 1994, and 0 for 1995, and then 1 for 1996 again.
I would think that I can use combination of by and sort but I have no clue how to do them. Please advice!
Many thanks in advance.
-S
Comment