Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: RE: Assigning id's to other observations (after expanding)
From
"Fernando Rios Avila" <[email protected]>
To
<[email protected]>
Subject
st: RE: Assigning id's to other observations (after expanding)
Date
Tue, 19 Apr 2011 13:44:57 -0400
Hi Marilyn,
I have an idea that might help you codding this particular issues.
Let me write it down in Steps, and hopefully that will be clear enough for
you to implement it
* im assuming file0 is the file where the data u show is.
1st identify id=parent id
Use File0, clear
Keep if id=parentid
Sort parentid
Save file1, replace
2nd identify merged firms
duplicate drops id parentid, force
keep id parentid
sort parentid
save file2, replace
3rd merge file 2 and file1
Use file2, clear
Merge parentid using file1
Save File4, replace
This file should have the duplicated section u were aiming for.
4th merge both files
Use file0, clear
Append using file4
Hope this helps
Fernando
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Ibarra-Caton,
Marilyn
Sent: Tuesday, April 19, 2011 1:24 PM
To: [email protected]
Subject: st: Assigning id's to other observations (after expanding)
I am having a hard time with coding to get the data as I need it. Any help
would be greatly appreciated!!!
My data looks like this:
id Parent id
1. Firm1 Firm3
2. Firm1 Firm3
3. Firm2 Firm3
4. Firm3 Firm3
In words what the data is telling me is that the parent id is the firm that
absorbed the firm in the id column. So in this case firm 3
absorbed (merged with) firm 1 and firm 2.
So I want the data to look like this:
1. Firm1 Firm3
2. Firm1 Firm3
3. Firm2 Firm3
4. Firm1 Firm3
5. Firm2 Firm3
So basically duplicate observation 4 and assign the id of observation 1 & 2
to one of the duplicate observations and assign the id of observation 3 to
the other duplicate observation. For the observation that I am going to
duplicate and assign a new id, it will always be the case that the
id==parent id for this observation before any manipulation
of the data. I know that to duplicate observation 4 I can use the
expand command.
Any thoughts on how to assign the id as I need it? Any help is greatly
appreciated!!
Thanks!
Marilyn.
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/