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

st: Help on data manipulation


From   "MITRA PINAKI (MAR1PXM)" <mar1pxm@ups.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Help on data manipulation
Date   Mon, 27 Sep 2004 17:29:30 -0400

Hello List,

    I have a dataset on multiple customer's revenue information like the
following:

Id    customer    revenue
Z11    xx1         y1
Z21    xx1         y2
Z31    xx1         y3
Z12    xx2         k1
Z22    xx2         k2
Z32    xx2         k3  and so on.

I need to create a new data based on the following criteria. If the sum of
revenue by customer is <=999, I need to write
Customer    revenue
xx1         sum of y
xx2         sum of k

But if the sum of revenue by customer is >999 and <=1998, I need to write
Id     Customer    revenue
001    xx1         999
002    xx1         sum of y-999
001    xx2         999
002    xx2         sum of k-999

and if the sum of revenue by customer is >1998 and <=2997, I need to write
Id     Customer    revenue
001    xx1         999
002    xx1         999
003    xx1         sum of y-1998
001    xx2         999
002    xx2         999
003    xx2         sum of k-1998

Can anyone please provide me any help on this?

Thank you,
Pinaki Mitra
*
*   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/



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