Hi everyone,
I prepare file for trading hours with beginning and close time of date.
Start | End |
09:00:00 | 17:00:00 |
08:30:00 | 14:52:00 |
09:00:00 | 13:00:00 |
I import this file into SAS and merge it with trading hours. Then I code and got error:
where (localtime >= start and localtime <= end);
ERROR: WHERE clause operator requires compatible variables.
Could you please advise how to make this code work? I tried to format time for START and END but the format time8. is not work.
Thank you,
This indicates that all variables are not the same type.
I'd expect all 3 to be numeric. Please check that they are. Use proc contents for example.
And where does Localtime come from?
Run Proc Contents or look at your variable properties in the SAS data set with your preferred method. One of those variables is not like the other in terms of variable type.
The FORMAT of a variable has nothing to do with the result of comparisons. There are many formats that could display any given value but unless you force the format to be used such as with Put(somevar,Aformatname.) the underlying values of the variable are used for comparison not the appearance of the format.
Did you find the error?
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.