BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
nishi1582
Calcite | Level 5

I am working on reconstruction of the Limit Order Book 

And have certain Sample Codes for SAS 

PROC IMPORT OUT= TEST.BAJAJAUTO
            DATAFILE= "C:\Users\Online_Class\Desktop\BAJAJ-AUTO.NS.csv"
            DBMS=CSV REPLACE;
     GETNAMES=YES;
     DATAROW=2;
RUN;

data test.Cash_trades_01012015;
INFILE "F:\RawData\CASH_Trades_01012015.DAT"   firstobs=1 lrecl =150;
input  Record_ind $ 1-2  segment $ 3-6  trade_no $ 7-22   trade_tm  23-36 symbol $ 37-46 series $ 47-48 trd_prc  49-56
trd_q  57-64  buy_order_no $ 65-80 buy_algo_ind 81 buy_client_flg 82 sell_order_no $ 83-98 sell_algo_ind 99 sell_client_flg 100;
run;


data test.Cash_orders_01012015;
INFILE "F:\RawData\CASH_Orders_01012015.DAT"   firstobs=1 lrecl =150;
input  Record_ind $ 1-2  segment $ 3-6  order_no $ 7-22   quote_tm  23-36 buysell $ 37 activity_typ $ 38 symbol $ 39-48
series $ 49-50 vol_discl  51-58 vol_orgnl  59-66  limit_prc  67-74 trig_prc 75-82 mkt_ord_flg $ 83 stp_loss_flg $ 84
ioc_flg $ 85 algo_ind 86 client_flg 87;
run;


data test.Cash_index_01012015;
INFILE "F:\RawData\CASH_Index_01012015.DAT"   firstobs=1 lrecl =150;
input  Record_ind $ 1-2  segment $ 3-6  date $ 7-14 trans_tm $ 15-22 value 23-30 value_junior 31-38;
run;




data test.ITC_Trades (drop = Record_ind segment series time1 time2 trade_tm buy_algo_ind buy_client_flg sell_algo_ind sell_client_flg);
      set test.Cash_trades_01012015;
      if symbol = "bbbbbbbITC";
      time1 = trade_tm/65536;
      time2 = MOD(time1,86400);
      time = time2/3600;
      period = int((time-9.25)*12)+1;
      if (Record_ind = 'RM')AND(segment = 'CASH')AND(series = 'EQ');
run;

data test.ITC_Orders (drop = Record_ind segment series time1 time2 quote_tm algo_ind client_flg);
      set test.Cash_orders_01012015;
      if symbol = "bbbbbbbITC";
      time1 = quote_tm/65536;
      time2 = MOD(time1,86400);
      time = time2/3600;
      period = int((time-9.25)*12)+1;
      if (Record_ind = 'RM')AND(segment = 'CASH')AND(series = 'EQ');
run;


data test.Order1;
      set test.ITC_Orders;
      if order_no = '2015010133369695';
run;


proc means data=test.Order1;
      var limit_prc;
run;

data test.Cash_trades_01012015_1;
      set test.Cash_trades_01012015;
      traded_vol = trd_prc*trd_q/100;
run;

proc sort data = test.Cash_trades_01012015_1;
      by symbol trade_tm;
run;

proc means data=test.Cash_trades_01012015_1;
      var traded_vol;
      by symbol;
      output out = Traded_Vol_Summary
      sum(traded_vol) = test.Daily_Traded_Vol;
run;



proc sort data = test.Cash_orders_01012015;
      by algo_ind mkt_ord_flg activity_typ;
run;

proc freq data = test.Cash_orders_01012015;
      by algo_ind;
      tables mkt_ord_flg*activity_typ;

 

These are generic codes to be applied to 2 data files in SAS on Demand 

1 ACCEPTED SOLUTION

Accepted Solutions
AMSAS
SAS Super FREQ

@nishi1582 

  1. What issue are you encountering? The more details you provide the better 
  2. Can you run the code and provide the log output (tip: use the Insert SAS Code button and paste the log output in there when posting back to communities).
  3. Can you isolate the issue to a specific data|proc step?

View solution in original post

3 REPLIES 3
nishi1582
Calcite | Level 5
But I am having problem with the implementation of codes
AMSAS
SAS Super FREQ

@nishi1582 

  1. What issue are you encountering? The more details you provide the better 
  2. Can you run the code and provide the log output (tip: use the Insert SAS Code button and paste the log output in there when posting back to communities).
  3. Can you isolate the issue to a specific data|proc step?
Kurt_Bremser
Super User

SAS on Demand does not have access to your desktop drive. You have to upload the files first with the upload facility of SAS Studio, and then use the correct UNIX path (right-click on the file in the Studio navigation pane) in your PROC IMPORT statement.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 502 views
  • 1 like
  • 3 in conversation