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

st: Modified Question: Manipulating an Unbalanced Panel

From   "ippab ippab" <>
Subject   st: Modified Question: Manipulating an Unbalanced Panel
Date   Fri, 21 Nov 2008 19:25:17 -0700

Hello All,

I just realized that I can generate a variable with the number of
panels with the following command: by  PanelNumber: gen CountSessions
= _N .

But, in my data, there is another variable which indicates if that
observation has any positive consumption.  I actually need to count
the number of positive consumptions for each panel.  There are
sessions without any consumption.  For example, I used "by
PanelNumber: gen CountSessions = _N   if  consumption>0".  This is
wrong because this gives CountSessions =2 even if a panel has one
session (observation) with positive consumption  and one session
(observation) without any consumption.

I found that the following command gives me the right output on the
screen: "by  PanelNumber: count   if  consumption>0".   However, I
don't know how to generate a variable to capture the output for the
command:  "by PanelNumber: count   if  consumption>0".  I would really
appreciate some help with this.

Thanks in advance!



---------- Forwarded message ----------
From: ippab ippab <>
Date: Fri, Nov 21, 2008 at 6:08 PM
Subject: st: Manipulating an Unbalanced Panel

Hi All,

I have an unbalanced panel data set where the number observations per
group varies from 1 to 9.  When I run the xtreg command, it includes
the panels (groups) that have only one observation.  I would like to
analyze panels that have at least 2 observations.  Could you please
help me in excluding panels with 1 observation from my analysis?  What
would be the easiest way to exclude panels (groups) with only one

Thanks a lot in advance!

Best regards,

*   For searches and help try:
*   For searches and help try:

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