How about this:
gen DV = 0
bysort code (year): replace DV = 1 if _n == 1
Scott
> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Dahlia El-Hawary
> Sent: Monday, April 11, 2005 3:59 PM
> To: [email protected]
> Subject: st: Identify 1st observation in each group in a panel data model
>
> Hi,
> I would very much appreciate your help with the following qusetion.
>
> I am working with an unbalanced annual panel data of over 50,000
> observations. The data set is made up of firms within countries over a
> time period from 1987 - 2002. I generated a variable called "code" as
> my panel identifier which assigns each firm a number. I also have
> a "countryid" giving each country a number. Year is the variable I am
> using for time.
>
> I would like to know how to identify the first observation of
> variable "X" for each firm in the panel ?. Specifically I would like
> to generate a dummy variable (DV==1) if the value of the first
> observation for variable X (for each firm) is less than "a", and DV==0
> otherwise.
>
> Thank you in advance,
>
> Dahlia El-Hawary
> PhD Candidate
> Economics Department
> George Wshington University
>
>
> *
> * 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/
*
* 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/