| Date: | Fri, 13 Jun 2003 13:08:59 +0200 |
| Reply-To: | Engelbert Smets <smets@PROVINZIAL.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Engelbert Smets <smets@PROVINZIAL.COM> |
| Subject: | Solved! Defining length in variable manner |
| Content-Type: | text/plain; charset=iso-8859-1 |
Thanks to All, especiall to Peter , Ian and Howard!
I take your solutions !
engelbert
Howard Schreier schrieb:
> Actually, including the string "best" in the code does nothing. There is no
> documented BESTw. informat. BESTw.d is apparently equivalent to w.d.
>
> On Thu, 12 Jun 2003 18:31:50 +0100, Peter Crawford
> <peter@CRAWFORDSOFTWARE.DEMON.CO.UK> wrote:
>
> >Jan gives the core of the solution
> >I'd like to pad this out a little
> >This code
> >>> input satz $80.;
> >>> bytes = input(scan(satz,1,' '),10.);
> >>> bytesuse = input(scan(satz,2,' '),10.);
> >>> bytesfre = input(scan(satz,3,' '),10.);
> >>> free = input(scan(satz,4,' '),10.) /100;
> >could be much improved
> >
> >I would suggest
> > input satz $80. @1 @;
> > informat bytes bytesuse bytesfre best32. Free best32.2 ;
> > input bytes bytesuse bytesfre free ;
> >This allows
> > each value to vary in width up to 32
> > accepts one or more blank leader and delimiters
> > takes an integer value for free and divides it by 100
> >Demo:
> > data ;
> > infile cards truncover ;
> > input satz $80. @1 @;
> > informat bytes bytesuse bytesfre best32. Free best32.2 ;
> > input bytes bytesuse bytesfre free ;
> > put (_all_)(=);
> > cards;
> > 123456 56789 677890 456789
> > 1 2 3 4
> > 9 8 7 6
> >;
> >
> >23 data ;
> >24 infile cards truncover ;
> >25 input satz $80. @1 @;
> >26 informat bytes bytesuse bytesfre best32. Free best32.2 ;
> >27 input bytes bytesuse bytesfre free ;
> >28 put satz= / (byt: free )(=);
> >29 cards;
> >
> >satz=123456 56789 677890 456789
> >bytes=123456 bytesuse=56789 bytesfre=677890 Free=4567.89
> >satz=1 2 3 4
> >bytes=1 bytesuse=2 bytesfre=3 Free=0.04
> >satz=9 8 7 6
> >bytes=9 bytesuse=8 bytesfre=7 Free=0.06
> >NOTE: The data set WORK.DATA3 has 3 observations and 5 variables
> >
> >
> >
> >Jan Selchau-Hansen <jan@*selchau-hansen.dk> writes
> >>Use the informat best.
> >>
> >>Jan
> >>
> >>
> >>"Engelbert Smets" <smets@PROVINZIAL.COM> skrev i en meddelelse
> >>news:3EE847D0.13F29EEC@provinzial.com...
> >>> Hi SAS-lers!
> >>>
> >>> We often use SAS to read the aoutput of other products as a flatfile.
> >>> One example is the punch-output by innovations fdreport.
> >>> Sometimes they change the lenth of fields an our programms fail.
> >>> Example of such code:
> >>>
> >>> input satz $80.;
> >>> bytes = input(scan(satz,1,' '),10.);
> >>> bytesuse = input(scan(satz,2,' '),10.);
> >>> bytesfre = input(scan(satz,3,' '),10.);
> >>> free = input(scan(satz,4,' '),10.) /100;
> >>>
> >>> The length/format "10." of the input-statement has formerly been "8.".
> >>> We noticed the change after some months.
> >>> Can anyone tell me an simple way to make this in a variable way ?
> >>>
> >>> TIA
> >>> e.smets
> >>> --
> >>> Freundliche Grüsse
> >>> Engelbert Smets
> >>> KIP 3 / Gruppenleiter Installations Management/Systemsoftware
> >>> c/o Provinzial Rheinland Versicherungen
> >>> Die Versicherung der Sparkassen
> >>> KIP3 / C00 / C00103
> >>> Provinzialplatz 1
> >>> 40591 Düsseldorf
> >>> Tel.: (0211) 978 2016
> >>> Fax: (0211) 978 1764
> >>> <mailto:smets@provinzial.com>
> >>
> >>
> >
> >--
> >Peter Crawford
> >
> >available for SAS consultancy contracts
--
Freundliche Grüsse
Engelbert Smets
KIP 3 / Gruppenleiter Installations Management/Systemsoftware
c/o Provinzial Rheinland Versicherungen
Die Versicherung der Sparkassen
KIP3 / C00 / C00103
Provinzialplatz 1
40591 Düsseldorf
Tel.: (0211) 978 2016
Fax: (0211) 978 1764
<mailto:smets@provinzial.com>
|