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.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 702 views
  • 2 likes
  • 3 in conversation