[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: Re: st: question on distribution of values
This is a correct answer so long as each -zip-
occurs once and once only within groups defined
by -order-. That is true of the example but
I didn't understand it to be given in the problem.
For example, a given order might include two assignments
to the same ZIP.
If it were true, then you can get there without
bys order : gen newqt = qt / _N
bys order: egen newqt=mean(Qt/_N)
> Here's an example of the data I'm working with:
> Order# Qt Zip
> 1 5 00011
> 1 5 00012
> 1 5 00013
> 1 5 00014
> 2 3 00021
> 2 3 00023
> 3 8 00031
> 3 8 00035
> 3 8 00036
> Here are my problems:
> 1. The quantity of packages (qt) listed does not correspond directly
to the zip code. For example, Order #1 requested 5 packages, to be
distributed among each of four zip codes, or 1.25 packages per unique
zip, not 5 packages per zip code.
> 2. I have yet to find the correct syntax that would allow me to
create a variable that would show the distribution of Qt among the zip
codes. I've played with egen, but can't get it to work.
> So my question is:
> how can I take one value of Qt (or if needed, an average of Qt),
within each unique Order# and divide it by the number of unique zip
codes by order#? Also, if it helps, the order number is listed each
> time the zip code changes, so a count of order# would probably work,
too, but I'd prefer to do it by Zip.
* For searches and help try: