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 2004, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 7 Jul 2004 11:47:03 -0400
Reply-To:     sashole@bellsouth.net
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Paul M. Dorfman" <sashole@BELLSOUTH.NET>
Organization: Sashole of Florida
Subject:      Re: long string -> hex -> decimal
Comments: To: "Chang Y. Chung" <chang_y_chung@HOTMAIL.COM>
In-Reply-To:  <20040707150521.SHHZ27312.imf13aec.mail.bellsouth.net@malibu.cc.uga.edu>
Content-Type: text/plain; charset="us-ascii"

Chang,

This is exactly what I meant. I suspect that SAS are not so eager to spend time mucking with their own data types and/or Data step compiler when they know that this kind of possibilities are available almost on tap. And I am just surmising here, but methinks that in the near future they will make javaobj more, uhm..., user-friendly in the SAS tradition - and more functionality accessible without the need to write wrappers. In fact, if the demand for big integer math were sufficiently high, I bet SAS could (and most likely would) provide a stand-alone DSCI object like BigInteger with corresponding methods. As you have just shown, it is not going to be very time-consuming from the development standpoint. Of course, with new computational and other functionality pieces piped through the DSCI window, the question remains if this is going to be - and if yes, then how - available in SQL. Is it at all reasonalbe to expect that if an mathematical operation can be performed in the Data step, SQL ought to be able to do the same? I am not so sure: SAS used to be quite functional without SQL altogether (although nowadays it is kind of hard to fancy).

Kind regards, ---------------- Paul M. Dorfman Jacksonville, FL ----------------

> -----Original Message----- > From: Chang Y. Chung [mailto:chang_y_chung@HOTMAIL.COM] > Sent: Wednesday, July 07, 2004 11:05 AM > To: SAS-L@LISTSERV.UGA.EDU; Paul M. Dorfman > Subject: Re: long string -> hex -> decimal > > On Tue, 6 Jul 2004 18:26:24 -0400, Paul M. Dorfman > <sashole@BELLSOUTH.NET> > wrote: > > ... > > > In fact, I > >bet by the time Richard has gone through the half of this, he has > >already concocted a scheme to insert a pipeline between some > existing > >BIGNUM > module > >and the Data step through the Javaobj window. > > Hi, > > Of course I am not Richard, but here are somethings what I > found out so far. HTH. > > Cheers, > Chang > > (1) java 1.1 and above has two classes called: BigInteger and > BigDecimal > (2) In sas 9 or above, these classes can be accessed from > within a data step like (9.1.2 on WinXP): > > data _null_; > length s $200; > declare javaobj A('java/math/BigInteger', "123456789"); > A.callStringMethod('toString', s); > put "A: " s; > run; > /* on log > A: 123456789 > */ > > (3)BigInteger class has all kinds of methods we need/want > (add, subtract, multiply, divide, abs, and, xor, mod, even > gcd...) but many of these methods return another BigInteger > Object -- alas, which sas javaobj cannot handle! > > (4)We can write a wrapper class so that they return strings > instead. To prove the concept, I wrote a very simple wrapper, > BigInt, that extends BigInteger and has a method sAdd that > returns a string, and it kinds of works, but not so pretty. > > BigInt.java-------------------------------------------------------- > import java.math.*; > > public class BigInt extends BigInteger { public BigInt(String val) { > super(val); // I am not sure if this is neccessary. > } > public String sAdd(String val) { > BigInteger a = new BigInteger(val); > BigInteger b = super.add(a); > return b.toString(); > } > } > -------------------------------------------------------------------- > > Once compiled, then in sas you can do something like the following: > > on sas 9.1.2 ------------------------------------------------------- > data _null_; > length s $200; > declare javaobj A('BigInt', repeat("1234567890", 6-1)); > A.callStringMethod('toString', s); > put "A : " s; > A.callStringMethod('sAdd', "1", s); > put "A + 1: " s; > run; > /* on log > A : 123456789012345678901234567890123456789012345678901234567890 > A + 1: 123456789012345678901234567890123456789012345678901234567891 > */ > -------------------------------------------------------------------- >


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