Statalist The Stata Listserver


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

st: RE: Grouped data and changing a variable


From   "David Harrison" <[email protected]>
To   <[email protected]>
Subject   st: RE: Grouped data and changing a variable
Date   Thu, 25 May 2006 13:05:10 +0100

Does the current value of e just represent -d=="Paper"-?

If so...

bysort a b c: egen newe = max(e)

(If not, -replace e = d=="Paper"- first)

David

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Catrina
Jordan
Sent: 25 May 2006 12:48
To: [email protected]
Subject: st: Grouped data and changing a variable

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/

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

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