Date: Sun, 10 Nov 2002 06:47:24 -0800
Reply-To: Jeff Morison <jmt_mtf@YAHOO.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Jeff Morison <jmt_mtf@YAHOO.COM>
Subject: Thanks - Re: How do I read this data?
In-Reply-To: <F33dZ06YO4OPXok84FT00001e9c@hotmail.com>
Content-Type: text/plain; charset=us-ascii
Paul and Sig, thank you so much for your responses,
you are right, my life would have been much easier if
I had access to the original dataset, unfortunately,
these reports exists in a central repository which are
created by another colleauge at a different location,
we only have access to this repository. We are in the
process of establishing better communication with the
other location to exchange the datasets. Meanwhile I
will definitely use Paul's solutions given here.
Thanks once again,
Jeff.
--- Paul Dorfman <paul_dorfman@hotmail.com> wrote:
> Jeff,
>
> As a general note, it would be much better idea to
> get hold of the data
> source used to generate this PPOC PRINT output than
> to read the latter.
> Since you have it on file, the job that produced the
> output could as well
> simply copy the SAS data set it was produced from to
> a permanent library,
> and that would be the end of it. I do realize,
> though, that in some
> production environments, it is of ten easier and
> faster to write your own
> code to parse an output listing than make certain
> folks change a single line
> of production code. (Sometimes it may sound as an
> anecdote, but just
> recently, I asked one of those folks - naively, I
> guess - if a meaningful
> report title would be better than "The SAS System"
> and was told in a rather
> harsh tone that since we had only 10 days left
> before the new cycle, we
> would not have enough time to write a technical
> design for this change, make
> the actual change, put the altered program through
> the UAT tests, and do
> everything needed to move the change to production -
> so this change would go
> as an enhancement into the next cycle provided that
> we would have enough
> human resources [sic!].) Another reason to do what
> you want would be having
> a report faxed to you scanned, etc. - those with
> experience working in a
> typical corporate setting know that the situation
> when a dozen of faxed
> sheets is the only source of information occurs
> surprisingly often.
>
> Writing a generic PRINT parser is perhaps futile
> given the variety of images
> the proc can display, but luckily, for this
> particular layout it is not that
> bad. You may want to try something along the
> following lines below. The idea
> is simple: Store the variables from the first block
> in an array, than add
> them to the variables coming fromt he wrapped
> portion:
>
> %let period = 8 ; * =25 in your case ;
>
> data inprint ( drop = _: ) ;
> informat trandate recv_dt date9. ;
> array in_one ( 6 ) org acct_nbr trandate
> tranamt recv_dt
> trancode ;
> array st_one ( &period, 6 ) _temporary_ ;
> infile cards truncover ;
> input @1 _row ?? @ ;
> if _row ;
> _grpno ++ (_row = 1) ;
> _blkno = 2 - mod (_grpno, 2) ;
> if _blkno = 1 then do ;
> input @1 _obs in_one (*) ;
> do _col = 1 to hbound (in_one) ;
> st_one (_row, _col) = in_one (_col) ;
> end ;
> end ;
> else /* if blkno = 2 */ do ;
> input @1 _obs site cus_zip score blk_cd:
> $char1. rule_fd ;
> do _col = 1 to hbound (in_one) ;
> in_one (_col) = st_one (_row, _col) ;
> end ;
> output ;
> end ;
> cards ;
> **** SORTED BY ACCT_NBR TRN_AMT RCVD_DATE ****
>
> OBS ORG ACCT_NBR TRANDATE TRANAMT RECV_DT
> TRANCODE
>
> 1 001 0000001 01NOV2002 215.00 01NOV2002
> 507
> 2 001 0000002 02NOV2002 216.00 02NOV2002
> 508
> 3 001 0000003 03NOV2002 217.00 03NOV2002
> 509
> 4 001 0000004 04NOV2002 218.00 04NOV2002
> 510
> 5 001 0000005 05NOV2002 219.00 05NOV2002
> 507
> 6 001 0000006 06NOV2002 220.00 06NOV2002
> 505
> 7 001 0000007 07NOV2002 229.00 07NOV2002
> 506
> 8 001 0000008 08NOV2002 234.00 08NOV2002
> 507
>
> **** SORTED BY ACCT_NBR TRN_AMT RCVD_DATE ****
>
> OBS SITE CUS_ZIP SCORE BLK_CD RULE_FD
>
> 1 0 656627302 572 A 1263
> 2 1 656627302 672 B 1263
> 3 2 656627302 672 C 1264
> 4 3 656627302 572 D 1265
> 5 4 656627302 572 A 1266
> 6 5 656627302 572 B 1267
> 7 1 656627302 572 A 1268
> 8 2 656627302 572 A 1263
> ;
> run ;
>
> proc print ; run ;
>
> Another viable approach would be to read the data
> from consecutive wrap
> blocks into SAS datasets or views and then merge
> them, as in, for example,
>
> data in1 (keep = org acct_nbr trandate tranamt
> recv_dt trancode)
> in2 (keep = site cus_zip score blk_cd rule_fd )
> ;
> informat trandate recv_dt date9. blk_cd $char1. ;
> array in1 (*) org acct_nbr trandate tranamt
> recv_dt trancode ;
> infile cards truncover ;
> input @1 _row ?? @ ;
> if _row ;
> _grpno ++ (_row = 1) ;
> _blkno = 2 - mod (_grpno, 2) ;
> if _blkno = 1 then do ;
> input @1 _obs in1 (*) ;
> output in1 ;
> end ;
> else /* if blkno = 2 */ do ;
> input @1 _obs site cus_zip score blk_cd:
> $char1. rule_fd ;
> output in2 ;
> end ;
> cards ;
> ......
> run ;
>
> data inprint ;
> merge in1 in2 ;
> run ;
>
> You should littpe problem extrapolating either of
> the pieces above should
> you have a printout wrapping more than 2 times. But,
> one again, I would try
> to get to the source whence it all has come.
>
> Kind regards,
> ---------------------
> Paul M. Dorfman
> Jacksonville, FL
> ---------------------
>
>
>
>
>
>
>
>
>
> ----Original Message Follows----
> From: Jeff Morison <jmt_mtf@YAHOO.COM>
> Reply-To: Jeff Morison <jmt_mtf@YAHOO.COM>
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: How do I read this data?
> Date: Fri, 8 Nov 2002 14:29:33 -0800
>
> Using SAS how do I read this data.
>
> I have a flat file containing 90000 records, the
> sample data looks like as below, which wraps after
> every 25 observations with the data of other fields.
>
> TIA,
> Jeff
>
>
> **** SORTED BY ACCT_NBR TRN_AMT RCVD_DATE ****
>
> OBS ORG ACCT_NBR TRANDATE TRANAMT RECV_DT
> TRANCODE
>
> 1 001 0000001 01NOV2002 215.00 01NOV2002
> 507
> 2 001 0000002 02NOV2002 216.00 02NOV2002
> 508
> 3 001 0000003 03NOV2002 217.00 03NOV2002
> 509
>
=== message truncated ===
__________________________________________________
Do you Yahoo!?
U2 on LAUNCH - Exclusive greatest hits videos
http://launch.yahoo.com/u2
|