I am trying to run the following code, which was provided ready made by the WRDS site.
I am pretty new to SAS but I have read some manuals and staff about dow-loop as well. but I get the error. I will be so grateful if you could point me to what is wrong with the code. I will appreciate your help so much!
the code:
and the error is about these two parts
where exactly is the semicolon expected and missed? or where is the mistake. I am mainly confused about this part of the code go to END TIMEOKLOOP;
Thank you in advance for your help. I desperately need this code to work for my thesis.
I am pretty new to SAS but I have read some manuals and staff about dow-loop as well. but I get the error. I will be so grateful if you could point me to what is wrong with the code. I will appreciate your help so much!
the code:
Code:
data matched /*Line 1*/
(drop = cqsymbol cqdate cqtime bid bidsiz ofr ofrsiz lagged_match timediff
exact_match rbid rofr rcqdate cqtime rcqtime rcqsymbol
rename = (mbid=BID mofr=OFR)
sortedby = symbol date time);
attrib CQSYMBOL length=$10. ; /*Line 2*/
attrib RCQSYMBOL length=$10.; /*Line 3*/
retain CQSYMBOL RCQSYMBOL CQDATE RCQDATE CQTIME RCQTIME BID RBID OFR ROFR
end_of_quotes_file; /*Line 4*/
set taq.ct_19980102 (where = (time >= '9:30:00'T AND time <= '16:00:00'T)) ; /*Line 5*/
do until (exact_match = 1 OR lagged_match = 1 OR end_of_quotes_file = 1 ); /*Line 6*/
if symbol>cqsymbol OR (symbol = cqsymbol AND date > cqdate) then
go to READQUOTE; /*Line 7*/
else /*Line 9-12*/
if cqsymbol > symbol OR cqdate>date then do; lagged_match=1;go to END TIMEOKLOOP;End;
else do; TIMEDIFF = time - cqtime; TIMEDIFF = time - cqtime; /*Line 13-15*/
if timediff = 5 then exact_match = 1; /*Line 16-25*/
else if timediff < 5 then lagged_match = 1;
else do;
READQUOTE: ;
RCQSYMBOL = CQSYMBOL;
RCQDATE = CQDATE;
RCQTIME = CQTIME;
RBID = BID;
ROFR = OFR;
set taq.cq_19980102 (rename = (symbol=CQSYMBOL date=CQDATE time=CQTIME) /*Line 26-30*/
where=(cqtime>='9:30:00'T AND cqtime<='16:00:00'T AND ofr>0 AND (ofr-bid)/bid<= 0.1))
end = end_of_quotes_file ;end;end; END TIMEOKLOOP: ; end;
/*Line 31-37: Depending on the break point encountered above, select the match array*/
if exact_match then do;
MBID = bid; label mbid = 'Matching Bid Price';
MOFR = ofr; label mofr = 'Matching Offer Price' ;
MTIME = cqtime; format mtime time. ; label mtime = 'Time of the Matching Quote' ;
Output;end;
else if lagged_match then do; /*Line 38-46*/
if symbol = rcqsymbol then do;MBID = rbid;MOFR = rofr;MTIME = rcqtime;output;End;
else do; MBID = .; MOFR = .; MTIME = .; output;End;end; /*Line 47-54*/
else if end_of_quotes_file then do;MBID=.;MOFR=.;MTIME=.;Output;end;/*Line 55-62*/
run;
and the error is about these two parts
Code:
20 if cqsymbol > symbol OR cqdate>date then do; lagged_match=1;go to END
20 ! TIMEOKLOOP;End;
----------
79
202
ERROR 79-322: Expecting a ;.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
Code:
34 end = end_of_quotes_file ;end;end; END TIMEOKLOOP: ; end;
---------- ---
79 161
ERROR 79-322: Expecting a ;.
ERROR 161-185: No matching DO/SELECT statement.
where exactly is the semicolon expected and missed? or where is the mistake. I am mainly confused about this part of the code go to END TIMEOKLOOP;
Thank you in advance for your help. I desperately need this code to work for my thesis.