1 The SAS System 16:26 Wednesday, September 14, 2011 NOTE: Unable to open SASUSER.REGSTRY. WORK.REGSTRY will be opened instead. NOTE: All registry changes will be lost at the end of the session. WARNING: Unable to copy SASUSER registry to WORK registry. Because of this, you will not see registry customizations during this session. NOTE: Copyright (c) 2002-2008 by SAS Institute Inc., Cary, NC, USA. NOTE: SAS (r) Proprietary Software 9.2 (TS2M2) Licensed to NEW YORK UNIVERSITY - STERN SCHOOL OF BUSINESS-T/R, Site 70062232. NOTE: This session is executing on the Linux 2.6.9-78.0.22.ELsmp (LINUX) platform. You are running SAS 9. Some SAS 8 files will be automatically converted by the V9 engine; others are incompatible. Please see http://support.sas.com/rnd/migration/planning/platform/64bit.html PROC MIGRATE will preserve current SAS file attributes and is recommended for converting all your SAS libraries from any SAS 8 release to SAS 9. For details and examples, please see http://support.sas.com/rnd/migration/index.html This message is contained in the SAS news file, and is presented upon initialization. Edit the file "news" in the "misc/base" directory to display site-specific news and information in the program log. The command line option "-nonews" will prevent this display. NOTE: SAS initialization used: real time 0.29 seconds cpu time 0.03 seconds 1 * 2 ________________________________________________________________________________________________________________________ 3 4 analyzeTrades.sas 5 Joel Hasbrouck 6 September 2011 7 8 This program runs on rnd.stern.nyu. It builds a dataset of transactions for one ticker symbol, plots the trade prices, 9 and computes descriptive statistics. 10 _______________________________________________________________________________________________________________________ 11 ; 12 options source nodate nocenter nonumber ps=max ls=110 orientation=landscape; 13 libname taq '/homedir/fin/fac/jhasbrou/public_html/ftp/phd2011Fall'; NOTE: Libref TAQ was successfully assigned as follows: Engine: V9 Physical Name: /homedir/fin/fac/jhasbrou/public_html/ftp/phd2011Fall 14 libname this '.'; NOTE: Libref THIS was successfully assigned as follows: Engine: V9 Physical Name: /homedir/fin/fac/jhasbrou/phd2011Fall 15 16 *__________________________________________________________________________________________________ 16 ! _____________________ 17 18 Subset a ticker symbol and print out a few records. 19 ___________________________________________________________________________________________________ 19 ! _____________________; 20 data this.myTicker; 21 set taq.ctqall; NOTE: Data file TAQ.CTQALL.DATA is in a format that is native to another host, or the file encoding does not match the session encoding. Cross Environment Data Access will be used, which might require additional CPU resources and might reduce performance. 22 * Next statement restricts the output to the symbol we want with nonmissing values for the bbid 22 ! and bofr 23 Outliers (with extremely high offers) and records after the 'normal' market close are removed. 24 'condFlag' flags trades with special condition codes.; 25 where symbol='ESSX' and bbid^=. and bofr^=. and bofr/bbid<5 and time<='16:10't and condflag^=1; 26 run; NOTE: There were 4471 observations read from the data set TAQ.CTQALL. WHERE (symbol='ESSX') and (bbid not = .) and (bofr not = .) and ((bofr/bbid)<5) and (time<='16:10:00'T) and (condflag not = 1); NOTE: The data set THIS.MYTICKER has 4471 observations and 14 variables. NOTE: DATA statement used (Total process time): real time 2.12 seconds cpu time 0.99 seconds 27 proc print data=this.myTicker (obs=10); 28 title "this.myTicker"; 29 run; NOTE: There were 10 observations read from the data set THIS.MYTICKER. NOTE: The PROCEDURE PRINT printed page 1. NOTE: PROCEDURE PRINT used (Total process time): real time 0.36 seconds cpu time 0.03 seconds 30 31 *__________________________________________________________________________________________________ 31 ! _____________________ 32 33 Pull off the records with trades. 34 ___________________________________________________________________________________________________ 34 ! _____________________; 35 data trades; * Put the values in a new dataset; 36 set this.myTicker; 37 where price^=.; 38 retain tradeSeqno 0; 39 tradeSeqno = tradeSeqno+1; 40 run; NOTE: There were 1715 observations read from the data set THIS.MYTICKER. WHERE price not = .; NOTE: The data set WORK.TRADES has 1715 observations and 15 variables. NOTE: DATA statement used (Total process time): real time 0.03 seconds cpu time 0.01 seconds 41 proc print data=trades (obs=50); 42 title "trades"; 43 run; NOTE: There were 50 observations read from the data set WORK.TRADES. NOTE: The PROCEDURE PRINT printed page 2. NOTE: PROCEDURE PRINT used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 44 45 *__________________________________________________________________________________________________ 45 ! _____________________ 46 47 Frequency counts for exchanges and condition codes 48 ___________________________________________________________________________________________________ 48 ! _____________________; 49 proc freq data=trades; 50 tables ex cond; 51 by symbol; 52 run; NOTE: There were 1715 observations read from the data set WORK.TRADES. NOTE: The PROCEDURE FREQ printed page 3. NOTE: PROCEDURE FREQ used (Total process time): real time 0.00 seconds cpu time 0.01 seconds 53 54 *__________________________________________________________________________________________________ 54 ! _____________________ 55 56 Distribution of sizes 57 ___________________________________________________________________________________________________ 57 ! _____________________; 58 proc univariate data=trades; 59 var size; 60 id date time ex cond; 61 by symbol; 62 run; NOTE: The PROCEDURE UNIVARIATE printed page 4. NOTE: PROCEDURE UNIVARIATE used (Total process time): real time 0.01 seconds cpu time 0.01 seconds 63 64 65 *__________________________________________________________________________________________________ 65 ! _____________________ 66 67 Plot trade prices - fancy 68 69 This procedure routes graphic output to an rtf file. The rtf file can be read in Microsoft Word and 69 ! other programs. 70 ___________________________________________________________________________________________________ 70 ! _____________________; 71 ods rtf file='analyzeTrades.rtf' style=analysis; NOTE: Writing RTF Body file: analyzeTrades.rtf 72 options nolabel; 73 goptions device=sasemf htext=1.8 ftext=duplex hsize=8in vsize=6in; 74 symbol1 v=dot h=.3; 75 proc gplot data=trades; 76 plot price*tradeSeqno=1; 77 by symbol; 78 title 'Trades by sequence number'; 79 run; NOTE: 90 records written to /homedir/fin/fac/jhasbrou/phd2011Fall/sasgraph.emf NOTE: 90 records written to /rnddata/sastmp/SAS_work196600004C98_rnd.stern.nyu.edu/#LN00015 NOTE: The above message was for the following BY group: symbol=ESSX 80 quit; NOTE: There were 1715 observations read from the data set WORK.TRADES. NOTE: PROCEDURE GPLOT used (Total process time): real time 1.02 seconds cpu time 0.77 seconds 81 symbol1; 82 symbol1 i=hiloc v=dot h=.1 color=black; 83 proc gplot data=trades; 84 plot price*date=1; 85 by symbol; 86 title 'High/low/close by date'; 87 run; WARNING: Greater than three node values for at least one observation in HILOC interpolation. Mean value used for tick placement. WARNING: Greater than three node values for at least one observation in HILOC interpolation. Mean value used for tick placement. NOTE: 72 records written to /homedir/fin/fac/jhasbrou/phd2011Fall/sasgraph.emf NOTE: 72 records written to /rnddata/sastmp/SAS_work196600004C98_rnd.stern.nyu.edu/#LN00025 NOTE: The above message was for the following BY group: symbol=ESSX 88 quit; NOTE: There were 1715 observations read from the data set WORK.TRADES. NOTE: PROCEDURE GPLOT used (Total process time): real time 0.69 seconds cpu time 0.62 seconds 89 ods rtf close; 90 endsas; NOTE: SAS Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414 NOTE: The SAS System used: real time 4.83 seconds cpu time 2.54 seconds