I need to set the value of a dummy variable = 1 for all observations of a given panelID, if it already equals 1 for any observations of that panelID
Considering the data example below, if for a given value of panelID the variable Rev==1 at any observation, I need to set Rev=1 for all observations with that panelID.
In this example, the result should be that the value of Rev == 1 for all observations where panelID==3 (i.e. years 1989 to 1994), while the value of Rev should remain 0 for all observations with panelIDs == 1 and 2.
Any help is greatly appreciated.
John
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long panelID float(DataYear Rev) 1 1989 0 1 1990 0 1 1991 0 1 1992 0 1 1993 0 1 1994 0 2 1989 0 2 1990 0 2 1991 0 2 1992 0 2 1993 0 2 1994 0 3 1989 0 3 1990 0 3 1991 0 3 1992 0 3 1993 0 3 1994 1 end format %ty DataYear label values panelID firmID label def firmID 1 "001004", modify label def firmID 2 "001009", modify label def firmID 3 "001011", modify
0 Response to Generalise value of dummy variable to all observations of a given panel ID
Post a Comment