LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (July 2002, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 25 Jul 2002 16:53:15 -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
Comments: To: "Balint, Jess" <JBalint@ALLDATA.NET>
Content-Type: text/plain; charset="iso-8859-1"



is short for

(var2 = var3) and (var3 = 7)

I see no reason why VAR2 should always be missing, but if it is then the result is 0 because a logical consequence (transitivity of equality) of the above expression is that

var2 = 7

and this is never true when VAR2 is missing.

Never trust what a programmer, or anyone else, tells you. Test it, decide for yourself, and be prepared to revise your opinion when more data is available to you. Of course even if you find that every example you consider leads to the truth of the statement you might wonder if SAS would give the same results tomorrow. If that is true it is time to take up another language or occupation. (However, note there are exceptions which may be allowed. Remember the result of some code can depend on the data, the operating system, the environment (both the out of disk space variety and magnets) as well as the language.)

However you must also understand things like (run under winows 98 SAS 8.2)

1602 data _null_ ; 1603 x = 7 ; 1604 y = 7 + 4.44e-16 ; 1605 z = x = y ; 1606 put z = ; 1607 run ;


The search for truth will always depend on what facts you find and your theoretical model of how to understand those facts.

-----Original Message----- From: Balint, Jess [mailto:JBalint@ALLDATA.NET] Sent: Thursday, July 25, 2002 3:48 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Double Assignment

How exactly would that work out?

var2 is always missing?!?

-----Original Message----- From: Sigurd Hermansen [mailto:HERMANS1@WESTAT.COM] Sent: Thursday, July 25, 2002 3:41 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Double Assignment

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!

Sig -----Original Message----- From: Jack Hamilton [mailto:JackHamilton@FIRSTHEALTH.COM] Sent: Thursday, July 25, 2002 3:22 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Double Assignment

Do you mean you have a hard time trusting this, i.e., that it will produce the answer of 0 or 1 correctly, or that you have a hard time believing that that's what the statement means?

Why don't you trust or believe it? Has something happened to make you think it doesn't work that way?

Will it help if you think of it as

var = (var1 = 7)


-- Manager, Technical Development METRICS Department, First Health West Sacramento, California USA

>>> "Balint, Jess" <JBalint@ALLDATA.NET> 07/25/2002 11:54 AM >>> Hello all. I have seen people here write code like "var2 = var1 = 7". From what they say var2 = 1 if var1 = 7 and var2 = 0 otherwise. I have a hard time trusting this. Is it correct though? Thanks.


Back to: Top of message | Previous page | Main SAS-L page