| Date: | Thu, 13 May 2004 09:18:31 -0700 |
| Reply-To: | Dale McLerran <stringplayer_2@YAHOO.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Dale McLerran <stringplayer_2@YAHOO.COM> |
| Subject: | Re: Scientific notation |
|
| In-Reply-To: | <246248784.1084464101757.JavaMail.osg@spnode33> |
| Content-Type: | text/plain; charset=us-ascii |
|---|
Kevin,
You can to use the input FUNCTION in order to convert the
character variable whose values contain scientific notations.
The following code demonstrates:
/* Data you initially presented with country and */
/* population. Population is a character variable. */
data one;
length country $ 6 population $ 10;
input country population;
datalines;
USA 1000000
CHINA 1.0016E+07
JAPAN 2.0616E+07
TURKEY 2351522
;
/* Read population variable using input function and informat e10. */
/* Rename population on set statement so name can be used for */
/* the numeric variable obtained when the input function is invoked */
data two;
set one(rename=(population=popchar));
population = input(popchar,e10.);
format population 10.;
run;
proc print data=two;
run;
HTH,
Dale
--- "CHRISTENSEN,KEVIN W" <chriske2@UFL.EDU> wrote:
> I tried this suggestion and best10. but I keep getting an error.
> Probably something wrong with my code:
>
> I send:
>
> data wbdata.pop4;
> set wbdata.pop3;
> informat _1960 e10.;
> run;
>
> I get back:
>
> 62 data wbdata.pop4;
> 63 set wbdata.pop3;
> NOTE: SCL source line.
> 64 informat _1960 e10.;
> ----
> 48
> ERROR 48-59: The informat $E was not found or could not be
> loaded.
>
> 65 run;
>
> It appears SAS is reading e10. format (and the best10. format) as
> if it should be a character format (given the $). I assume this
> is because in the original dataset the population figures are
> considered to be character. So now what?
>
> On Thu May 13 11:48:54 EDT 2004, Harry Droogendyk
> <harry.droogendyk@RBC.COM> wrote:
>
> > See Ew. informat, where w = width.
> >
> > -----Original Message-----
> > From: CHRISTENSEN,KEVIN W [mailto:chriske2@UFL.EDU]
> > Sent: Thursday, May 13, 2004 11:42 AM
> > To: SAS-L@LISTSERV.UGA.EDU
> > Subject: Scientific notation
> >
> >
> > I have a SAS dataset that looks like the following:
> >
> > COUNTRY POPULATION
> > USA 1000000
> > CHINA 1.0016E+07
> > JAPAN 2.0616E+07
> > TURKEY 2351522
> >
> > The population variable is read in as a character and I'd like to
> > read it as a number. Unfortunately the scientific notation in
> > some observations will make it difficult (I think). Any ideas
> > around this?
> > --
> > CHRISTENSEN,KEVIN W
> >
> > ------------------------------------------------------------
> > This e-mail may be privileged and/or confidential, and the sender
> > does not waive any related rights and obligations. Any
> > distribution, use or copying of this e-mail or the information it
> > contains by other than an intended recipient is unauthorized. If
> > you received this e-mail in error, please advise me (by return
> > e-mail or otherwise) immediately.
> >
> > Ce courrier électronique est confidentiel et protégé.
> > L'expéditeur ne renonce pas aux droits et obligations qui s'y
> > rapportent. Toute diffusion, utilisation ou copie de ce message
> > ou des renseignements qu'il contient par une personne autre que
> > le (les) destinataire(s) désigné(s) est interdite. Si vous
> > recevez ce courrier électronique par erreur, veuillez m'en aviser
> > immédiatement, par retour de courrier électronique ou par un
> > autre moyen.
> >
> > ============================================================
> >
> >
>
>
>
> --
> CHRISTENSEN,KEVIN W
=====
---------------------------------------
Dale McLerran
Fred Hutchinson Cancer Research Center
mailto: dmclerra@fhcrc.org
Ph: (206) 667-2926
Fax: (206) 667-5977
---------------------------------------
__________________________________
Do you Yahoo!?
Yahoo! Movies - Buy advance tickets for 'Shrek 2'
http://movies.yahoo.com/showtimes/movie?mid=1808405861
|