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 (November 2009, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 26 Nov 2009 10:28:48 -0500
Reply-To:     "Lane, Jim" <jim.lane@RBC.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Lane, Jim" <jim.lane@RBC.COM>
Subject:      Re: How to read in numbers in scientific notation
Comments: To: Daniel Fernández <fdezdan@GMAIL.COM>
In-Reply-To:  A<20e5d12f0911260632t6932d68cxcae7d638e34b8d47@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Daniel,

Thanks for this. Specifying a width on the best format fixed me up perfectly. There were too many digits on my input for the default to handle. Missing values was never a problem since I already had code to selectively, if not elegantly, translate NaN to zero.

/JL

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Daniel Fernández Sent: 2009, November, 26 9:32 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: How to read in numbers in scientific notation

hi,

use input function with ?? to avoid LOG telling you about missing values.

data test; input a $30.; cards; 1.2549414716e+00 8.8518272018e-01 NaN Statistics are significant ; run;

data need; set test; b=input(a,?? best32.12); run;

Daniel Fernandez Barcelona

2009/11/26 Lane, Jim <jim.lane@rbc.com>: > Hi, All > > I'm sure this is just a brain cramp but I have a text csv file which > contains inter alia numbers in scientific notation such as > > "1.2549414716e+00","8.8518272018e-01","NaN","2.1401241918e+00" > > Since I also have to deal with the "NaN" values I'm using code like > this: > > input s $ u $ n $ t $ ; > if s="NaN" then system=0; else system=input(s,best.); > if u="NaN" then user=0; else user=input(u,best.); > if n="NaN" then nice=0; else nice=input(n,best.); > if t="NaN" then total=0; else total=input(t,best.); > > This seems to work fine until I get numbers with negative exponents > which seem to be ignored. In the above example the variable "user" > ends up as 8.518 rather than 0.8518 as it should be. > > What am I doing wrong here? Is there some other format I should be > using? > > TIA > > -Jim > > > > ______________________________________________________________________ > _ > > 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. > _______________________________________________________________________

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.


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