1 The SAS System 14:50 Wednesday, September 7, 2011 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 2.82 seconds cpu time 0.05 seconds 1 * 2 ________________________________________________________________________________________________________________________ 3 4 firstLook.sas 5 Joel Hasbrouck 6 September 2011 7 8 This program runs on rnd.stern.nyu. It builds a dataset for one ticker symbol, computes daily closing prices, 9 plots them, and computes descriptive statistics. 10 _______________________________________________________________________________________________________________________ 11 ; 12 options source nodate nocenter nonumber ps=44 ls=110 orientation=landscape; 13 libname taq '/homedir/fin/fac/jhasbrou/public_html/ftp/phd2011Fall'; The SAS System 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 where symbol='ESSX' and bbid^=. and bofr^=. and bofr/bbid<5 and time<='16:10't and condFlag^=1; 25 run; NOTE: There were 6148 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 6148 observations and 14 variables. NOTE: DATA statement used (Total process time): real time 3.32 seconds cpu time 1.36 seconds 26 proc print data=this.myTicker (obs=10); 27 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 1.09 seconds cpu time 0.04 seconds The SAS System 28 29 *__________________________________________________________________________________________________ 29 ! _____________________ 30 31 Get daily closing prices and total daily volume 32 ___________________________________________________________________________________________________ 32 ! _____________________; 33 data dailyData; * Put the values in a new dataset; 34 dailyVol = 0; 35 do until (last.date); 36 set this.myTicker; 37 by date; 38 dailyVol = sum(dailyVol,size); * The sum(.) function treats missing values as zero (which is what 38 ! we want here). 39 if price^=. then closingPrice=price; 40 end; 41 * If there are no transactions, set the closing price to the midpoint of the last bid and ask.; 42 if closingPrice=. then closingPrice = (BBid+BOfr)/2.; 43 output; 44 run; NOTE: There were 6148 observations read from the data set THIS.MYTICKER. NOTE: The data set WORK.DAILYDATA has 84 observations and 16 variables. NOTE: DATA statement used (Total process time): real time 0.10 seconds cpu time 0.00 seconds 45 proc print data=dailyData (obs=10); 46 run; NOTE: There were 10 observations read from the data set WORK.DAILYDATA. NOTE: The PROCEDURE PRINT printed page 2. NOTE: PROCEDURE PRINT used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 47 48 *__________________________________________________________________________________________________ The SAS System 48 ! _____________________ 49 50 Plot closing prices - basic 51 ___________________________________________________________________________________________________ 51 ! _____________________; 52 proc plot data=dailyData; 53 plot closingPrice*date; 54 run; 55 56 57 *__________________________________________________________________________________________________ 57 ! _____________________ 58 59 Plot closing prices - fancy 60 61 This procedure routes graphic output to an rtf file. The rtf file can be read in Microsoft Word and 61 ! other programs. 62 ___________________________________________________________________________________________________ 62 ! _____________________; 63 ods rtf file='firstLook.rtf' style=analysis; NOTE: Writing RTF Body file: firstLook.rtf 64 goptions device=sasemf htext=1.8 ftext=duplex hsize=8in vsize=6in; 65 symbol1 v=dot; NOTE: There were 84 observations read from the data set WORK.DAILYDATA. NOTE: The PROCEDURE PLOT printed page 3. NOTE: PROCEDURE PLOT used (Total process time): real time 3.52 seconds cpu time 0.06 seconds 66 proc gplot data=dailyData; 67 plot closingPrice*date; 68 by symbol; 69 run; NOTE: 16 records written to /homedir/fin/fac/jhasbrou/phd2011Fall/sasgraph.emf NOTE: 16 records written to /rnddata/sastmp/SAS_work81140000767D_rnd.stern.nyu.edu/#LN00015 NOTE: The above message was for the following BY group: Stock Symbol=ESSX 70 quit; The SAS System NOTE: There were 84 observations read from the data set WORK.DAILYDATA. NOTE: PROCEDURE GPLOT used (Total process time): real time 0.45 seconds cpu time 0.19 seconds 71 72 *__________________________________________________________________________________________________ 72 ! _____________________ 73 74 Basic time series statistics 75 ___________________________________________________________________________________________________ 75 ! _____________________; 76 ods exclude iacfgraph pacfgraph; * Suppresses inverse- and partial-autocorrelation graphs; 77 proc arima data=dailyData; 78 identify var=closingPrice stationarity=(dickey=3); 79 identify var=closingPrice(1); * analysis of first differences; 80 run; 81 82 83 84 85 86 87 ods rtf close; 88 89 90 91 92 93 endsas; NOTE: The PROCEDURE ARIMA printed pages 4-6. NOTE: PROCEDURE ARIMA used (Total process time): real time 0.36 seconds cpu time 0.06 seconds NOTE: SAS Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414 NOTE: The SAS System used: real time 12.07 seconds The SAS System cpu time 1.79 seconds