Date: Fri, 10 Nov 2000 19:31:40 GMT
Reply-To: Charles_S_Patridge@PRODIGY.NET
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Charles Patridge <Charles_S_Patridge@PRODIGY.NET>
Organization: Deja.com - Before you buy.
Subject: Re: SAS Language
Michelle,
The answer can be found under Tips and Techniques on my web site -
www.sconsig.com as TIP 00150.
Paul,
I like your answer this time around!!! It agrees with the answer you
supply to us a while back - love your consistency <grin>
HTH,
Charles Patridge
Email: Charles_S_Patridge@prodigy.net
Web: http://www.sconsig.com
In article <F62rBLSAQV6uPDVniSn00000982@hotmail.com>,
Paul Dorfman <paul_dorfman@HOTMAIL.COM> wrote:
> Michelle,
>
> Kim LeBouton has asked a similar question (in a more general context)
in
> the past. I am taking the liberty to reproduce a part of my own reply
after
> the sig line.
>
> Kind regards,
> =========================
> Paul M. Dorfman
> Jacksonville, Fl
> =========================
>
> One trendy solution would be to input the field as a character string
S and
> then use a dynamic informat
>
> inputn(compress(s,'.'),compress('s370fzdt'
> || put(length(s)-1,best.)||'.'
> || put(length(s)-index(s,'.')-1,best.)))
>
> but it looks like a pretty crude kludge. A thingie as simple as
>
> input(compress(s,'-+'),best.)*(1-2*(index(s,'-')>0))
>
> looks much more elegant (and will execute much faster, too). If you
have no
> beforehand idea whether the sign is leading or trailing or absent at
all,
>
> abs(input(compress(s,'-+'),best.))*(1-2*(index(s,'-')>0))
>
> will work in all those situations at the expense of the extra call to
ABS.
> For example,
>
> data _null_;
> input s: $15.;
> n = input(compress(s,'-+'),best.)*(1-2*(index(s,'-')>0));
> put n=;
> cards;
> 1234.5678-
> -123456.78
> +1.2345678
> 987654321.1+
> 12345678901
> ;
> run;
> --------------------
> n=-1234.5678
> n=-123456.78
> n=1.2345678
> n=987654321.1
> n=12345678901
>
> michelle_kay@MY-DEJA.COM wrote:
>
> >I need to import a numeric field into SAS from a flat file that I
> >downloaded from mainframe system. All negative numbers have the
minus
> >signs in the back of the number instead of in front of the number.
How
> >do I read this and convert it into a correct format?
> >
> >original Desired
> >70248- -70248
> >45478 45478
> >21838- -21838
> >45780- -45780
> >55454 55454
> >45015 45015
> >
> >Thank you for your help.
> >
> >Michelle Kay
> >
> >
> >
> >
> >Sent via Deja.com http://www.deja.com/
> >Before you buy.
>
>
________________________________________________________________________
_
> Get Your Private, Free E-mail from MSN Hotmail at
http://www.hotmail.com.
>
> Share information about yourself, create your own public profile at
> http://profiles.msn.com.
>
--
Charles Patridge - PDPC, Ltd.
172 Monce Road - Burlington, CT 06013 USA
Phone: 860-673-9278 or 860-675-9026
Email: Charles_S_Patridge@prodigy.net - Web: www.sconsig.com
Sent via Deja.com http://www.deja.com/
Before you buy.
|