Date: Fri, 29 Aug 2008 10:42:21 -0500
Reply-To: yingtao <yingtaoliu@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: yingtao <yingtaoliu@GMAIL.COM>
Subject: stock trade summary by SAS
Content-Type: text/plain; charset=ISO-8859-1
Hi All,
I am wondering what is the simple way to get the profit/loss summary for the
stock transactions for tax purpose.
i.e.1. loss/profit separate by year;
I am thinking to get each transaction's cost, then for long position, we can
use (sell price-cost)*quantity to get the profit/loss.
For short position, use (buy price-cost)*quantity to get the profit/loss. Just
feel hard to code the cost for each transaction.
sample data as follows:
Obs Symbol Quantity Price type
TradeDate Amount
1 A -400 9.1752 Sell
03/05/2007 3663.03
2 A 400 11.6
Buy 03/05/2008 -4647
3 A 100 9.4875
Buy 03/04/2008 -955.75
4 A -100 9.8352 Sell
03/03/2008 976.5
5 A -100 9.8826 Sell
03/03/2008 981.24
6 A 55 12.05
Buy 02/26/2008 -662.75
7 A 45 12.05
Buy 02/26/2008 -549.25
8 B -200 6.06 Sell
03/18/2007 1211.98
9 B -300 6.06 Sell
03/18/2008 1810.98
10 B 100 6.5
Buy 03/18/2008 -657
11 B 78 6.5
Buy 03/18/2008 -507
12 B 322 6.5
Buy 03/18/2008 -2093
13 C 100 20.9
Buy 03/19/2008 -2097
14 C -100 20.6521
Sell 03/18/2008 2058.18
15 F 300 10
Buy 05/05/2007 -3000
16 F -100 6 Sell
05/06/2007 600
17 F -100 8 Sell
05/07/2008 800
thanks.
Tao