Date: Thu, 25 Jul 2002 17:10:08 -0400
Reply-To: Ian Whitlock <WHITLOI1@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ian Whitlock <WHITLOI1@WESTAT.COM>
Subject: Re: Double Assignment
Content-Type: text/plain; charset="iso-8859-1"
Jonathan,
You missed,
>>>>>>>>>>>>>>>>>>
TABLE NOTE 8:
An exception to this rule occurs when two comparison operators surround a
quantity. For example, the expression x<y<z is evaluated as (x<y) and (y<z).
>>>>>>>>>>>>>>>>>>>
in the section on evaluation of expressions from the online documentation.
= also obeys the exception noted above as do all the comparison operators.
Reason: Probably too much C in your background, or too great a desire for
consistency.
IanWhitlock@westat.com
-----Original Message-----
From: goldbergj@MSNOTES.WUSTL.EDU [mailto:goldbergj@MSNOTES.WUSTL.EDU]
Sent: Thursday, July 25, 2002 4:43 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: Double Assignment
Sigurd Hermansen <HERMANS1@WESTAT.COM> says:
I would not trust a programmer who leaves out the parentheses. What rules
of
operator precedence apply in multiple assignments across the same operator?
Try to explain how SAS will evaluate
var1=var2=var3=7;
to someone other than a committed (or soon to be) SAS programmer!
Try to explain it to me! According to the documentation, = is a group 5
operator, and pairs are evaluated left to right. If so, explain:
1 data _null_;
2 v1 = 7;
3 v2 = 7;
4 v3 = v1=v2=7; *should be 0;
5 put v3=;
6 run;
v3=1
Now, either
4 v3 = v1=(v2=7); *should be 0; or
4 v3 = (v1=v2)=7; *should be 0;
get v3=0.
I thought I understood this; obviously I'm overlooking something.
Jonathan Goldberg
Missouri Alcoholism Research Center
Washington University School of Medicine
40 N. Kingshighway, Suite One
St. Louis, MO 63108
314-286-2212