Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Matching Transaction Types in Stata


From   Aleksandar Zaklan <azaklan@diw.de>
To   statalist@hsphsun2.harvard.edu
Subject   st: Matching Transaction Types in Stata
Date   Tue, 8 Nov 2011 17:20:00 +0100

Dear Statalist, 

I have a dataset of asset transactions, with the same type of asset for all transactions, for a number of account_number/country/time combinations. I can tell the amount transacted by the serial numbers of the asset, since they are unique, do not overlap and have no gaps between them. 

In this case, some amount of the asset is deposited in the account (indicated by type==12) and then the amount is transferred out again (type==9), either partially or totally. However, for each outflow I need to know the corresponding inflow transaction. 

So for each observation of type==9 I need to go through all 1 through _N observations of type 12 and check if (start(type==9)[_n]>=start(type==12[_n]) & end(type==9)[_n]<=end_12[_n]). 

trans_date_time_num	type	acct	country start	        end      	amount
04may2005 13:50:24	12	13	US	1224047567	1224051164	3598
04may2005 13:50:24	12	13	US	1224162810	1224164466	1657
04may2005 13:50:24	12	13	US	1224179325	1224181915	2591
04may2005 13:50:24	12	13	US	1224160354	1224162809	2456
04may2005 13:50:24	12	13	US	1224164467	1224165667	1201
15feb2006 18:45:18	12	13	US	848318723	848330225	11503
20apr2006 13:36:34	9	13	US	1224050304	1224051164	-861
20apr2006 13:36:34	9	13	US	1224164467	1224165667	-1201
20apr2006 13:36:34	9	13	US	1224160354	1224162809	-2456
20apr2006 13:36:34	9	13	US	1224162810	1224164466	-1657
20apr2006 13:36:34	9	13	US	848318723	848330225	-11503
20apr2006 13:36:34	9	13	US	1224179325	1224181915	-2591
31oct2006 11:59:33	12	13	US	1002622938	1002639697	16760

I would highly appreciate any pointers on how to do this! 

Best wishes,
Aleks
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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   |   Site index