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: merge with random assignment
From
R Zhang <[email protected]>
To
[email protected]
Subject
st: merge with random assignment
Date
Thu, 20 Mar 2014 23:41:22 -0400
Dear Statalisters,
I need to merge two tables
Table 1 data structure is as follows:
Input str6 Ionumber naics
"1110" 111
"1111A0" 11111
"1111A0" 11112
"1111B0" 11113
"1111B0" 11119
"1111B0" 11114
"1111B0" 11116
"111200" 1112
"111335" 111335
end
Table 2
Input str6 ionumber aij
“1111A0” 1
“1111A0” 2
“1111B0” 0.1
“1111B0” 0.6
end
I want to merge two tables using ionumber. The goal is to add naics to
talbe 2. As you can tell, sometimes ionumber in table 1 correspond to
multiple naics values. In such cases, I would like to randomly assign
the ionumber to one of the 4 possible naics (11113, 11119, 11114,
11116). My real table 1 has cases that one ionumber could correspond
to upto 8 different naics.
Could you please share some thoughts on how to do such random assignment merge?
Thanks,
Rochelle
*
* 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/