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
@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.
@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.
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.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.