Buy minus Sell alternate value columns
Posted: 05 August 2015 09:55 PM   [ Ignore ]
Newbie
Rank
Total Posts:  4
Joined  2015-07-29

Hi Joost,

Hi all,

I am trying to resolve an error I am facing where I cant get my BUY - SELL Variable. A sample of my table is attached with this post:


There are different CUSIP (companies) at different dates.

Since my BUY and Sell variables are of different columns and they are alternate (which means stock j has either buy or sell at only one time), when i try to do a BUY - SELL as BUY_SELL command, the BUY_SELL is variable empty.

What I am trying to achieve is a BUY - SELL variable, something like SUM(BUY) - SUM (SELL) = mean(difference) etc.


Image Attachments
Untitled.gif
Profile
 
 
Posted: 06 August 2015 05:45 PM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  901
Joined  2011-09-19

hi Nonchtan,

I’m afraid I don’t get the logic. I would expect that a ‘Sell’ to follow a ‘Buy’ for long positions, and the reverse for short positions. So there would always a ‘pair’ of transactions that open and close the position. In your screenshot there are times though that you have several ‘sell’ transactions in a row. Should repeated transactions be ignored (i.e., ignore a buy following a buy, and same for sell)?

In any event, you probably will appreciate the ‘RETAIN’ keyword for a data step (that will allow you to carry forward variables over rows).

Best,

Joost

 Signature 

To reply/post new questions: Please use the group WRDS/SAS on Google Groups! http://groups.google.com/d/forum/wrdssas

Profile