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: replacing values problem
From
Paula Smith <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: replacing values problem
Date
Wed, 19 Mar 2014 20:20:09 +0000
Hi all,
I have a database of parents and children with variables indicating parent =
ID and country of parent:
ID parentID country
1 . UK
2 1
3 1
4 . USA
5 4
6 4
7 . France
8 7
I'm wanting to put give the children the same value of 'country' as the par=
ent. The 'country' variable is a string.
So far I've got:
quietly levelsof country if country!="", local(parentlocation)
quietly levelsof parentID if parentID!=. , local(parent)
quietly levelsof ID if parentID!=. , local(child)
foreach l of local child {
quietly replace country=`parentlocation' if ParentID==`parent'
}
But I'm getting an r(198) error. Am I over-complicating things? Can anyone =
help?
Thanks in advance,
Paula
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/