Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: concordance

From   "Michael Blasnik" <>
To   <>
Subject   st: Re: concordance
Date   Thu, 17 Feb 2005 07:46:20 -0500

If I understand you correctly, you want the sum of category B for each value of category A, but if a category B appears multiple times, you want to apportion its value across each occcurrence (maybe I am generalizing too much from your problem?). If that is what you want, then this should work:

bysort category_b: gen catb_count=_N
gen b2=b/catb_count
egen catb_sum=sum(b2), by(category_a)

Michael Blasnik

----- Original Message ----- From: "Karen Jackson" <>
To: <>
Sent: Thursday, February 17, 2005 5:59 AM
Subject: st: concordance


I have a concordance (for a large number of codes) that has a structure something like this:


1 10

2 10


I have values corresponding to each CATEGORY B code and want to aggregate these into CATEGORY A codes. My problem is that when the code appears in both CATEGORY A and CATEGORY B, as in the of CATEGORY B code "10", I wish to add only 50% of "10" into CATEGORY A code "1" and 50% into CATEGORY B code "2". Any ideas?

Thanks for your help,

Karen Jackson

* For searches and help try:
*   For searches and help try:

© Copyright 1996–2021 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index