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 (October 1996, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sat, 5 Oct 1996 14:01:07 EDT
Reply-To:     whitloi1@WESTATPO.WESTAT.COM
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Ian Whitlock <whitloi1@WESTATPO.WESTAT.COM>
Subject:      Re: Format for numeric representation of PIB character varia
Comments: To: Karsten Self <kmself@PMSQUARED.COM>

Subject: Format for numeric representation of PIB character variables Summary: Deja vu Respondent: Ian Whitlock <whitloi1@westat.com>

Karsten Self <kmself@PMSQUARED.COM> wants to store huge numeric values in 4 bytes of character data.

>I'm exploring the possibility of saving storage space by coding >numeric integer values into a character field. This corresponds to >unsigned integers in other programming languages. These are serially >incremented counters, no negative values, and I expect a large >quantity of data.

As he points out, he can get 4,294,967,296 different values in 4 character bytes, but only 2,097,152 different numbers in 4 byte numeric variables.

When I began programming, I worked for a firm, that stored counts in each half byte to keep the record small. The consequence was that every program was significantly harder to write and took much longer to execute. At the time the data base had 600 reels of tape which needed updating twice a week, so storage space was at a premium. Each record was 4096 bytes and contained many small counts. They managed to make the system work (with an army of 150 programmers), so who can knock it.

Unlike the above problem, it is far from clear what is to be gained by using 4 character bytes instead of 8 numeric bytes. But the conversion routines are trivial to code in SAS

store = input ( put ( numin , hex8. ) , $hex8. ) ; numout = input ( put ( store , $hex8. ) , hex8. ) ;

Hence the view

data v ( drop = temp ) / view = v ; set &data ( rename = ( store = temp ) ) ; store = input ( put ( store , $hex8. ) , hex8. ) ; format store comma14. ; run ;

would appear to solve the problem wherever needed. (In case anyone has deja vu, this is just another twist on converting from character to numeric and has been discussed all too often on SAS-L.)

As for a format the SAS/TOOLKIT will allow one to construct such an algorithm at a lot more expense, but I doubt whether much is too be gained in doing so.

Ian Whitlock


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