BookmarkSubscribeRSS Feed
thanhnguyenhtl
Calcite | Level 5

Hi everyone,

I prepare file for trading hours with beginning and close time of date. 

StartEnd
09:00:0017:00:00
08:30:0014:52:00
09:00:0013: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,

 

 

3 REPLIES 3
ChrisNZ
Tourmaline | Level 20

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.

ballardw
Super User

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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 924 views
  • 0 likes
  • 3 in conversation