# Re: st: question on distribution of values

 From Jeph Herrin To statalist@hsphsun2.harvard.edu Subject Re: st: question on distribution of values Date Tue, 10 Oct 2006 12:18:37 -0400

```how about

bys order: egen newqt=mean(Qt/_N)

?

Andrea King wrote:
```
```Dear Statalist Users,

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.

Thanks,

Andrea

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

```
```*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```