03-13-2012 11:31 AM
I need to change in a macro of a standard table:
the condition emerge by the other condition aetdate=. or aetdate >= factdat
in this statment
variable=%str(emerge & trtrel)
my question is, the change has to be:
variable=%str( (aetdate=. or aetdate >= factdat) & trtrel)
variable=%str( aetdate=. or aetdate >= factdat & trtrel)
03-14-2012 07:42 AM
i suppose to prevent the resolution of & or a semicolon ( if i need to.
Is a tot file tom, only i got for default %str()...and i need to put the condition inside of this bracket:
my question is :
this condition has to be inside of this bracket as:
a) with brackets (aetdate=. or aetdate >= factdat) & trtrel
b) or withouth brackets aetdate=. or aetdate >= factdat & trtrel
which is the difference?
03-14-2012 07:44 AM
is a tot file, i.e a macro with a default expression:
%str()...and i ned to put the condition a) or b) , i am not sure........ inside of this braket..like %str(condition)...only i can change condition, anyone else.
03-14-2012 08:10 AM
Looks like you didn't need %str before, but you will need it now because of the equal sign and the added parentheses.
Yes, you need the parentheses. Without them, SAS would logically evaluate AND first (before OR). With them, you can force SAS to evaluate OR first which is what your example requires.
When referring to parentheses inside %STR, you need to add an extra percent sign:
variable = %str( %(aetdate=. or aetdate > factdat%) & trtrel)
03-15-2012 07:38 PM
Thank you for the answer.
I did not know SAS evaluate AND first then OR.
Why I need to putthis %before (?...I dont use these porcentages before ( as my option a of my post, and the macro works right.
03-15-2012 07:52 PM
Before, the parentheses were part of the %STR function, and they told SAS where to start and where to end applying the %STR function. That still applies to the exterior parentheses in the sample solution. They tell %STR where to start and where to end, so those parentheses don't need the extra %.
These new parentheses are inside the %STR function. The %STR function is being applied to those characters. That's why %STR requires %( and %). Since the "inside" parentheses are balanced -- you have both a left then a right parenthesis -- you can try leaving out the % and see what happens. It might work, but I'm not able to test that right now. It will work using %( and %).
03-15-2012 08:42 PM
try and let me know, thanks.
your option: variable = %str( %(aetdate=. or aetdate > factdat%) & trtrel)
my option: variable = %str( (aetdate=. or aetdate > factdat) & trtrel)
we will see if there are some differences.