Date: Thu, 25 Jul 2002 15:57:43 -0500
Reply-To: goldbergj@MSNOTES.WUSTL.EDU
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: goldbergj@MSNOTES.WUSTL.EDU
Subject: Re: Double Assignment
Content-type: text/plain; charset=us-ascii
Aha! Because of the implied "and"!
Jonathan Goldberg
Missouri Alcoholism Research Center
Washington University School of Medicine
40 N. Kingshighway, Suite One
St. Louis, MO 63108
314-286-2212
----- Forwarded by Jonathan Goldberg/MARC/Psychiatry/Medicine/Washington
University on 07/25/02 04:17 PM -----
Jonathan Goldberg
To: SAS-L
07/25/02 03:43 PM cc:
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