Statalist The Stata Listserver


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

st: Grouped data and changing a variable


From   "Catrina Jordan" <[email protected]>
To   <[email protected]>
Subject   st: Grouped data and changing a variable
Date   Thu, 25 May 2006 12:47:45 +0100

Dear All
I have a set of data where I need to replace a variable's content
depending if it is in a group and one of the variables contains a
certain value.
 
For example
a	b	c		d	e
101	1	01-May-06	Paper	1
101	1	01-May-06	Disc	0
101	1	01-May-06	Electronic	0
102	1	02-May-06	Paper	1
102	1	02-May-06	Disc	0
103	2	02-May-06	Disc	0
103	2	02-May-06	Electronic0

 
I know that the first three observations are in the same group (using
the egen command for variable a, b and c) and the second group is the
next two observations and so on but in each group if variable d contains
"Paper" then I want all the observations in the group for variable e
changed to a 1.  If there is no "Paper" in the group then to leave as
they are.


So to end up with
a	b	c		d	e
101	1	01-May-06	Paper	1
101	2	01-May-06	Disc	1
101	3	01-May-06	Electronic	1
102	1	02-May-06	Paper	1
102	2	02-May-06	Disc	1
103	2	02-May-06	Disc	0
103	2	02-May-06	Electronic0
 
Cheers
Catrina
 
 


                                        

*
*   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/



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