X-Mailer: Ezmail v3.8 <Tue Sep 15 08:31:15 1992 richardh>
Status: U
Newsgroups: bit.listserv.sas-l
Date:         Tue, 15 Sep 1992 08:40:15 WST
Reply-To:     Richard Hockey <richardh@EPISUN.EPIDEM.UWA.EDU.AU>
From:         Richard Hockey <richardh@EPISUN.EPIDEM.UWA.EDU.AU>
Subject: re: Length and numeric precision
Comments: To: sas-l@ohstvma.acs.ohio-state.edu

In reply to the mail from <SAS-L@OHSTVMA.ACS.OHIO-STATE.EDU>...
-------------------------------------------------------------------------------
>Dear sas-l'ers,
>
>    Interesting discussion on use of numeric variables.  Although
>    my preference is to grab at all the precision I can get, it
>    seems that the original question posed has been lost!  That is,
>    how to most efficiently store the data?
>
>        Why not store David Alderton's integers (0-99) in character
>    format?  Certainly would save space.  In fact, depending on the
>    range of integers, character variables will always do this.

I agree, this is how I store most of my large datasets of survey data as
most of the responses are short integers (usually 1 digit) which represent
a categorical response (i.e. 1=yes 2=no etc) and would never require any
sort of numerical manipulation.

>
>        There will also be no problems with BY and MERGE statements,
>    so another potential problem has been avoided.  Character variables
>    always work in these circumstances.
>
>       Uh-oh!  What if you actually want to do something with these
>    variables in a numeric sense?  Simply do a character to numeric
>    conversion and you are on your way to the party.  One useful
>    thing about this is that *you* must specify the amount of
>    precision you want,  immediately before embarking upon your
>    calculating journey.  So,  you can't later excuse yourself for
>    thinking it was something it was not.

SAS does this automatically but the log tends to look a bit untidy so
for the sake of neatness I sometimes do something like x=100*input(y,1.);
where y is a character variable. The automatic conversion is always to length
8 as far as I am aware.

>
>        But isn't all this programming time consuming?  Probably no
>        more than all the fuzzy if statements and fuzz statements and
>        all the what-nots necessary to use numeric data!
>
>     It would even be less so if we could ask SAS to come up with a
>     simplified character-to-numeric conversion routine that would
>     make it as easy as falling off your tower configuration.  Maybe
>
>        data example;
>           CHARTONUM  {list of variables}  {length};

I wrote myself a little macro to do just this. It converts all character
variables in a dataset to numeric or vice versa.



>
>        ...  go on about your business GLUMming as to death ...
>
>      Anyone wish to comment on this very strange idea from an
>      (anti)-social scientist?
It's not strange ;-)

>
>                                    Robert Terry
>                                    Asst. Professor
>                                    Psychology - Social and Health
>                                    Duke University
>                                    Durham, NC 27708
>
> P.S. Flames are welcome, they appear to be synonymous with the
>      badge of courage.
>
>PPS.  I hope that my suggested CHARTONUM statement would be implemented
>       on all SAS systems.
>


| Richard Hockey                    email:richardh@episun.epidem.uwa.edu.au   |
| Department of Public Health       phone:+61 9 389-3463        _--_|\        |
| University of Western Australia   fax:  +61 9 389-3648       /      \       |
| NEDLANDS WA 6009                                             *_.--._/       |
| Australia                                                          v        |