As far as I know, SAS times should be numeric, so I should be able to loop through the day in 15-minute intervals by converting the minutes to seconds. When I try to do that, though, I get the following error:
ERROR: A character operand was found in the %EVAL function or %IF
condition where a numeric operand is required. The condition
was: &start_time
ERROR: The %FROM value of the %DO TIME loop is invalid.
ERROR: A character operand was found in the %EVAL function or %IF
condition where a numeric operand is required. The condition
was: &end_time by &interval_seconds
ERROR: The %TO value of the %DO TIME loop is invalid.
ERROR: The macro TAQDATA will stop executing.
Code:
%let start_time = '9:30:00't; /* starting time*/
%let end_time = '16:00:00't; /* ending time (per Andersen)*/
%let interval_seconds = (15 * 60); /* interval length in seconds, note that total daily trading time should be divisible by interval length*/
%let no_intervals = ((&end_time-&start_time)/ &interval_seconds ) ; /*number of intervals based on start/end time and length of intervals*/
%do year = &start_year %to &end_year;
%do month = 1 %to 12;
%do time = &start_time %to &end_time by &interval_seconds;
%if (&year = 1996 or (&year = 2004 and &month>= 7)) %then %let fdatevar = datef;
%else %let fdatevar = fdate;
%let currentyear = %sysevalf(%substr(&year,3,2)); /*last two digits of year*/
%if %length(&month) = 1 %then %let currentmonth = 0&month;
%else %let currentmonth = &month; /* month in MM format*/
%let ctime=&time;
%let monthyearint = ¤tyear¤tmonth&cinterval;
%if not(&year = &start_year and &month < &start_month) and not(&year = &end_year and &month > &end_month) and not (&ctime> &end_time) %then %
;
Any ideas greatly appreciated.