# Re: st: create a _n time variable panel data

 From "Ricardo Guimaraes" To statalist@hsphsun2.harvard.edu Subject Re: st: create a _n time variable panel data Date Wed, 07 Jun 2006 13:25:15 +0200

```Vielen Dank,

Ich probierte jetz.
scuss
Ricardo

On 07 Jun 2006 11:58:53 +0100
Dirk Nachbar <Dirk.Nachbar@dwp.gsi.gov.uk> wrote:
```
Ricardo

try this (untested)
sort idd i t
by idd i: gen vn=_n if v1!=. & v2!=.
by idd i: egen ob=sum(v1!=. & v2!=.)

Gruesse nach Bonn

Dirk Nachbar
Assistant Economist
Pensim2
Department for Work and Pensions
WC2N 6HT London
020 796 28531

ricardo.guimaraes@uni-bonn.de 07/06/2006 09:52

To
statalist@hsphsun2.harvard.edu@internet
cc

Subject
st: create a _n time variable panel data

Dear Members,
I have the following panel data .

?????????????
how to calculate
| t idd i v1 v2 | vn ob |
|---------------------------------------------------|
1. | 1 560036 1 3 . | 1 4|
2. | 1 560036 2 2 . | 1 4|
3. | 1 560036 3 3 1 | 1 4|
4. | 1 560036 4 6 1 | 1 4|
5. | 1 560036 5 3 1 | 1 4|
|---------------------------------------------------|
6. | 2 560036 1 1 . | 2 4|
7. | 2 560036 2 2 6 | 2 4|
3. | 2 560036 3 3 1 | 2 4|
8. | 2 560036 4 3 7 | 2 4|
9. | 2 560036 5 2 1 | 2 4|
|---------------------------------------------------|
10.| 3 560036 1 . . | . .|
11.| 3 560036 2 . . | . .|
12.| 3 560036 3 . . | . .|
13.| 3 560036 4 . . | . .|
14.| 3 560036 5 . . | . .|
|---------------------------------------------------|
15.| 4 560036 1 1 . | 3 4|
16.| 4 560036 2 2 . | 3 4|
17.| 4 560036 3 7 1 | 3 4|
18.| 4 560036 4 3 1 | 3 4|
19.| 4 560036 5 5 1 | 3 4|
|---------------------------------------------------|
20.| 5 560036 1 1 . | 4 4|
21.| 5 560036 2 2 . | 4 4|
22.| 5 560036 3 8 1 | 4 4|
23.| 5 560036 4 3 1 | 4 4|
24.| 5 560036 5 3 1 | 4 4|
|---------------------------------------------------|

"t" is time (let's say, by month); "idd" identifies a family; "i" an individual in the family;
"V1", "v2" are variables about characteristics of individuals. The panel is formulated in
a rotating basis: families are observed no more than 4 times (months) in a year. In my table
they would be the variable "ob". However, the observation are not taken in a row. They "jump"
some months (like month 3 in my example), where the members of the family are not observed. I do not have the variables "Vn" and "ob".
Question:

How to create two variables, 1) "vn": 2) "ob" ) for each individual saying:

1) "vn" : a sequence (_n) of the months that the individuals are observed. For instance, in the
time "t" the individuals of the family were not observed.
2) "ob" : the total number (_N) of times that the individual were observed. Note that in some
variables the values are (.), but the individual was observed.

sincerely,

ricardo
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/

On entering the GSI, this email was scanned for viruses by the Government Secure Intranet (GSi) virus scanning service supplied exclusively by Cable & Wireless in partnership with MessageLabs.
The MessageLabs Anti Virus Service is the first managed service to achieve the CSIA Claims Tested Mark (CCTM Certificate Number 2006/04/0007), the UK Government quality mark initiative for information security products and services. For more information about this please visit www.cctmark.gov.uk

**********************************************************************
This document is strictly confidential and is intended only for use by the addressee. If you are not the intended recipient, any disclosure, copying, distribution or other action taken in reliance of the information contained in this e-mail is strictly prohibited.
Any views expressed by the sender of this message are not necessarily those of the Department for Work and Pensions.
If you have received this transmission in error, please use the reply function to tell us and then permanently delete what you have received.
Please note: Incoming and outgoing e-mail messages are routinely monitored for compliance with our policy on the use of electronic communications.
**********************************************************************

The original of this email was scanned for viruses by Government Secure Intranet (GSi) virus scanning service supplied exclusively by Cable & Wireless in partnership with MessageLabs.
On leaving the GSI this email was certified virus free.
The MessageLabs Anti Virus Service is the first managed service to achieve the CSIA Claims Tested Mark (CCTM Certificate Number 2006/04/0007), the UK Government quality mark initiative for information security products and services. For more information about this please visit www.cctmark.gov.uk
```Ricardo Guimaraes
Junior Researcher
Center for Development Research (ZEF) - University of Bonn
Walter-Flex Str., 3
53113 Bonn
Germany
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```