----- Original Message -----
From: "Nisha Malhotra" <malhotra@econ.bsos.umd.edu>
To: <statalist@hsphsun2.harvard.edu>
Sent: Wednesday, September 11, 2002 11:33 PM
Subject: st: generating a 0,1 variable which depends on lag values
> Hi,
>
> I am facing a problem creating a binary variable.
> I have a large panel data set. The three important variables are Year,
Industry, Action taken by an industry ( variable that takes the value 0 if
no action was taken and 1 if one action was taken and 2 if two actions were
taken and so on )
>
> The data looks something like this
> Year Industry Action
> 90 A 0
> 91 A 0
> 92 A 2
> 93 A 0
> 90 B 1
> 91 B 0
> 92 B 0
> 93 B 1
>
> I want to create a binary variable say BB, which takes the value 0 if no
prior action(in the previous years) has been taken by an industry and 1 if
some positive action has been taken by an industry in the previous years.
>
> Year Industry Action BB
> 90 A 0 0
> 91 A 0 0
> 92 A 2 1
> 93 A 0 1
> 90 B 1 1
> 91 B 0 1
> 92 B 0 1
> 93 B 1 1
>
> I would really appreciate if someone can help me out with this.
> Thanks in advance
>
>
> *
> * 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/\
try:
.sort industry
.by industry: gen A1=sum(Action)
.gen A2=cond(A1>0,1,0)
*
* 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/