Hi Monica and welcome to SAS!
If I'm understanding your question correctly, you are trying to get an average of say, var1, in a specific date and time range. It looks like your date and time fields are separate. Is that correct? If you make the date and time 1 field, this is the format you would use in a where statement if querying:
Datetime Constant Time
'17OCT1991:14:45:32'DT 32 seconds past 2:45 p.m., 17 October 1991
'17OCT1991:12:5'DT 12:05 p.m., 17 October 1991
'17OCT1991:2:0'DT 2 AM, 17 October 1991
'17OCT1991:0:0'DT midnight, 17 October 1991
I'm sure others might have a better suggestion, but I would simply do:
proc sql;
create table work.x as
select
avg(var1)
from
work.y
where
datetime between '17OCT1991:14:45:32'DT and '18OCT1991:14:45:32'DT;
quit;
You'll have to tweak this, but maybe this will help?
Also, this link is a great reference page to use - it's helped me a lot!
http://support.sas.com/onlinedoc/913/docMainpage.jsp