Date: Thu, 4 Dec 2003 15:13:39 -0700
Reply-To: Jack Hamilton <JackHamilton@FIRSTHEALTH.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Jack Hamilton <JackHamilton@FIRSTHEALTH.COM>
Subject: Re: THANKS***PROBLEM USING RANUNI AND FLOORFUNCTIONTOCREATEFAKED
ATA***
Content-Type: text/plain; charset=us-ascii
Dale said that he didn't know of any language which allows variables
passed as parameters to be updated. That sounded like a call for an
example. I don't know of an example in SAS, and I'm not sure whether
it's possible using the current internal SAS calling conventions, but
VBA and PL/I qualify as programming languages.
In some circumstances, passing and modifying parameters by value is a
good programming practice, given the alternative of putting the values
into global variables. In other languages, there might be better
alternatives - an object-oriented approach, for example. That's now
available in VBA, but wasn't in PL/I when I was using it, and isn't in
the SAS data step now.
--
JackHamilton@FirstHealth.com
Manager, Technical Development
Metrics Department, First Health
West Sacramento, California USA
>>> "Ian Whitlock" <WHITLOI1@WESTAT.com> 12/04/2003 1:57 PM >>>
Jack,
Was your decision to switch from SAS to Visual Basic arbitrary or
necessary?
In what SAS functions are arguments passed by reference? It seems to
me
clear that Dale was considering only the "SAS like part" of other
languages
when he made the statement.
Would you consider, your example VB code an illustration of a good
programming practice, or just a legal one?
I recently ran across a quote, "I try to be right no more than
necessary." I
would change it to, "It is better to be reasonable than right." I do
not
think that is an arbitrary decision. :)
IanWhitlock@westat.com
-----Original Message-----
From: Jack Hamilton [mailto:JackHamilton@FIRSTHEALTH.COM]
Sent: Thursday, December 04, 2003 4:36 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: THANKS***PROBLEM USING RANUNI AND
FLOORFUNCTIONTOCREATEFAKE
DATA***
"Dale McLerran" <stringplayer_2@YAHOO.COM> wrote:
>I don't know of any language which allows variables passed in as
>arguments to a function to be updated.
This Visual Basic program:
=====
Sub outer()
Dim x As Integer, y As Integer
x = 1
Debug.Print x
y = Inner(x)
Debug.Print x; y
End Sub
Function Inner(ByRef z As Integer) As Integer
z = 3
Inner = 2
End Function
=====
prints this:
=====
1
3 2
=====
I no longer have access to a PL/I compiler, but I'm pretty sure that it
also
allows the modification of arguments passed by reference.
I'm also pretty sure, based on the documentation, that Perl allows the
value
of a parameter passed by reference; Davis Cassell can confirm or deny
that.
--
JackHamilton@FirstHealth.com
Manager, Technical Development
Metrics Department, First Health
West Sacramento, California USA