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

st: Panel data - generating variabels & looping


From   "Alexander Severinsen" <[email protected]>
To   "Statalist" <[email protected]>
Subject   st: Panel data - generating variabels & looping
Date   Tue, 22 Oct 2002 02:22:03 -0700

Dear members of the list,

I have panel data looking like this,

Member ID	Date		Purchase (grams)
1001		20010813	600
1001		20010817	1000
1001		20010824    ...
1002
1002
etc

Does anyone know or have any tips on how to generate a new variabel that
gives the distance in days between the different dates? Eg.

Member ID	Date		DateD (Distance)
1001		20010813	4
1001		20010817	7
1001		20010824	...
etc

Based on the new variabel DateD i also want to generate a new variabel
ConsumptionRate that is:
ConsumptionRateA = Purchase/Distance and then RateB=RateA/number of
observations. Eg

Member ID	Date		Purchase (grams) DateD	RateA			RateB
1001		20010813	600			4     600/4=150		150+142.8=292.8
1001		20010817	1000			7	1000/7=142.8	150+142.8=292.8
1001		20010824    ...			...

Any help would be greatly appreciated.


Regards,
Mvh,
Alexander Severinsen
markedsfakta as

t: 777 56167
m: 957 83425

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index