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]
Re: st: Subset of data into new file
From
Steven Archambault <[email protected]>
To
[email protected]
Subject
Re: st: Subset of data into new file
Date
Fri, 20 Aug 2010 12:03:27 -0600
Okay, my repeats are the group names. I think my data example did not
go through as I set it up. But, duplicates drop worked. The key
though, is to tell stata which variables to keep first. In my case
keep Group GroupAvgSize
duplicates drop
...then I can merge as normal to give each indv the group average (in
the larger data set).
Thanks!
-Steve
On Fri, Aug 20, 2010 at 11:13 AM, Eric Booth <[email protected]> wrote:
> <>
>
> It's not clear from your example which dataset your "repeats" are in, but you can use -duplicates drop- to remove them before the merge , e.g.
>
> ****************!
> clear
> Indv (Group) Size GroupAvgSize
> 1 a 2 4
> 2 a 4 4
> 3 a 6 4
> 1 b 3 3
> 2 b 4 3
> 3 b 2 3
> end
> duplicates drop Indiv Group, force
> save using, replace
>
> clear
> inp Indiv str5(Group)
> 1 a
> 2 a
> 3 a
> 4 a
> 5 a
> 1 b
> 2 b
> 3 b
> 4 b
> 5 b
> end
> duplicates drop Indiv Group, force
> merge 1:1 Indiv Group using using.dta
> ta _m
> ****************!
>
> ~ Eric
> __
> Eric A. Booth
> Public Policy Research Institute
> Texas A&M University
> [email protected]
> Office: +979.845.6754
>
>
>
> On Aug 20, 2010, at 12:00 PM, Steven Archambault wrote:
>
>> Hi all,
>>
>> I have data about groups, from which I am calculating means for the groups.
>>
>> Indiv Group Size GroupAvgSize
>> 1 a 2 4
>> 2 a 4 4
>> 3 a 6 4
>> 1 b 3 3
>> 2 b 4 3
>> 3 b 2 3
>>
>>
>> Then, I want to merge the group avg size with a larger set of data
>> containing the same groups, but a larger set of individuals (where
>> size is not recorded).
>>
>> Indv Group
>> 1 a
>> 2 a
>> 3 a
>> 4 a
>> 5 a
>> 1 b
>> 2 b
>> 3 b
>> 4 b
>> 5 b
>>
>> Is there a way to do this without exporting the data with GroupAvgSize
>> to a spreadsheet, where I could crop out the repeats?
>>
>> Thanks!
>>
>> -Steve
>> *
>> * 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/
>
*
* 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/