Hi Guys,
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:
a)with brackets:
variable=%str( (aetdate=. or aetdate >= factdat) & trtrel)
b)withouth brackets
variable=%str( aetdate=. or aetdate >= factdat & trtrel)
Thanks.
Why do you have the %STR()? It looks like you are referencing actual variables why would you need to do macro quoting of any type?
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?
Not sure what you are talking about.
It is in data step or Macro ?
Ksharp
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.
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)
Good luck.
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.
Thanks.
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 %).
Good luck.
Please,
try and let me know, thanks.
your option: variable = %str( %(aetdate=. or aetdate > factdat%) & trtrel)
or
my option: variable = %str( (aetdate=. or aetdate > factdat) & trtrel)
we will see if there are some differences.
michtka,
I tried a similar test, and found I could omit the extra %. But if you want to learn, you should try testing it yourself.
Good luck.
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!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.