BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

All, 
  Can somebody kindly help point out what I am doing wrong in the following code ? 

 

%Let DesHour   = %sysfunc(hour(%sysfunc(tzoneu2s(%sysfunc(tzones2u(%sysfunc(datetime()))),america/los_angeles))));
%Put NOTE: Current Hour in Desired Location is : &DesHour; 
%Let Cond2  = %eval(&DesHour == 11); 
%Put NOTE: Condition For Hour Of Day Is: &Cond2; 

 

Best 
Uday 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

@UdayGuntupalli wrote:

All, 
  Can somebody kindly help point out what I am doing wrong in the following code ? 

 

%Let DesHour   = %sysfunc(hour(%sysfunc(tzoneu2s(%sysfunc(tzones2u(%sysfunc(datetime()))),america/los_angeles))));
%Put NOTE: Current Hour in Desired Location is : &DesHour; 
%Let Cond2  = %eval(&DesHour == 11); 
%Put NOTE: Condition For Hour Of Day Is: &Cond2; 

 

Best 
Uday 


SAS does not use double == to test for equality, it uses a single = sign. Change that to a single equal sign and you'll get a 1. 

Note that 1 is true and 0 is false. 

View solution in original post

3 REPLIES 3
Reeza
Super User

@UdayGuntupalli wrote:

All, 
  Can somebody kindly help point out what I am doing wrong in the following code ? 

 

%Let DesHour   = %sysfunc(hour(%sysfunc(tzoneu2s(%sysfunc(tzones2u(%sysfunc(datetime()))),america/los_angeles))));
%Put NOTE: Current Hour in Desired Location is : &DesHour; 
%Let Cond2  = %eval(&DesHour == 11); 
%Put NOTE: Condition For Hour Of Day Is: &Cond2; 

 

Best 
Uday 


SAS does not use double == to test for equality, it uses a single = sign. Change that to a single equal sign and you'll get a 1. 

Note that 1 is true and 0 is false. 

Reeza
Super User
FYI - I updated your subject since it did not reflect your question.
Tom
Super User Tom
Super User

By codding 11==11 you essentially tested this condition:

11=(=11)

Now since 11 does not equal nothing the first test generates results 0 , so you have

11=0

since 11 does not equal 0 the result is false, or zero.

 

If you had tested 

0==11

It would have resulted in true since 0 does equal 0.

 

So you are testing whether the macro variable is zero, not whether it is 11.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1077 views
  • 2 likes
  • 3 in conversation