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
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.
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!
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.