DATA Step, Macro, Functions and more

SAS_Order classification

Posts: 33

SAS_Order classification

[ Edited ]
Super User
Posts: 17,840

Re: SAS_Order classification

Khaladdin wrote:

Hi all,

I have a tricky question about the SAS programming. I need to classify limit order book according to its aggressiveness. I will be happy if someone can help me. I need to use the method that developed by Hagstromer (2014). Method says that:
We categorize buy orders by aggressiveness on a scale from (1) to (10). The least aggressive action on the buy side is to cancel an existing buy order, and such messages are assigned type (1). Limit orders that do not lead to immediate execution are classified as follows: (2) is a buy order quoted at a price lower than 0.5% below the best bid price; (3) is a buy order quoted below the current best bid price, but less than 0.5% below the current best bid price; and (4) is a buy order posted at the best bid price. Among buy orders that are priced between the best bid and ask prices, we distinguish those that are cancelled if they are not executed immediately (5) from those that are allowed to rest in the order book (6). The remaining buy order categories are marketable limit orders that result in immediate execution: (7) is a marketable limit buy order without price impact; (8) is a large marketable limit buy order that consumes all the available shares quoted at the best ask and withdraws the residual volume, that is, the volume that is not executed at the best ask; (9) is a price changing marketable limit buy order that posts the residual volume as a limit order in the book; and (10) is a price-changing marketable limit order that is “walking the book,” that is, is executed at several different price levels.
Many thanks in advance for your help.

1. Post some sample data and anything you've tried so far

2. Narrow your question - dumpimg your entire assignment on here and expecting someone to do all the work isn't helpful. Narrow your question ro a single more detailed idea and you can build on that. If you need multiple questions in the process that's fine. 

3. Sample data and expected output. 

Posts: 3,478

Re: SAS_Order classification

I assume the data includes variables for the type of order (cancel existing, limit, buy below,...) and also variables on the price, bid, etc. when the order was created. Then just use a series of IF-THEN/ELSE statements or a SELECT-WHEN statement in the DATA step to assign the agressiveness level.  It that is not something you know how to do, then post the format of your data.

Posts: 7,363

Re: SAS_Order classification

I think the following paper should help:


Additionally, that paper's authors site the following link for providing some of the SAS code they used:


Art, CEO,


Super User
Posts: 10,500

Re: SAS_Order classification

Looks like $200 hour work to me.  Smiley Happy

Ask a Question
Discussion stats
  • 4 replies
  • 5 in conversation