Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: add rows in order to balance the panel

From   "Sara Valentini" <>
To   <>
Subject   st: add rows in order to balance the panel
Date   Wed, 14 Feb 2007 21:02:12 +0100

Dear Statlisters,
I'm working with an unbalanced panel database. I would like to solve a simple problem, but I cannot figure out how to solve it. I try to explain my problem describing my data, it's easier!
My unit of analysis is customers (i). I observe these customers for some quarters (t). The database has the following structure (more or less):


i   t  Y

1  1  40

1  3  30

1  4  20 

2  1  10

2  2  20

2  3  20

2  4  30


For simplicity, suppose I have only 4 quarters (t=1, 2, 3, 4) and two customers. This panel is unbalanced. As you can see, customer n. 1 doesn't have information for quarter 2. 

Y are the dollar spent but customers to buy some items. 

I would like to add the following row to my database:

i  t  Y

1  2  0


That is, I would like to add the non purchase option. For example customer 1 does't buy anything at time 2, so I would like to put a 0 in Y. 

Specifically, I would like to find the way to add rows in my database in order to have the same number of rows for each customers (4 in this example), rows with null values for some of the variables of the database (such as Y). 


I have a huge number of records so I cannot do that manually J, or using excel or SPSS. 


If you know a specific command to solve this problem, or have an idea I appreciate any suggestion. 


I sincerely thank everybody for reading my e-mail



*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index