Date: Thu, 29 Jun 2000 07:26:39 -0400
Reply-To: Richard DeVenezia <radevenz@IX.NETCOM.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Richard DeVenezia <radevenz@IX.NETCOM.COM>
Organization: MindSpring Enterprises
Subject: Re: Scan a record to see what variables are included,
without reading the data into a dataset
Paula:
Consider this abstraction...
sNvM represents segment N variable N
s1vA represents the 5 character 'segments on tape' variable in segment 1
s2vB represents the 5 character 'segments on tape' variable in segment 2
...
s5vE represents the 5 character 'segments on tape' variable in segment 5
PsNvM represents the offset position (consider initial position as 1) of
variable M within the segment N record.
Of course you will have to write some macro, call it MakeInpt;
To keep things legible and understandable, you probably want a two pass.
Pass One to determine which records from the first record of the tape
Pass Two to actualy input the data (macro generates the input statement
based on Pass One information)
Your first order of business is to determine the value of the 'segments on
tape' variable from the first record on the tape.
If this variable is located at the same offset in each segment you have no
troubles.
[Ps1vA = Ps2vB = Ps3vC = Ps4vD = PsvE]
input @Ps1vA whichrec $CHAR5.;
The macro MakeInpt would use the value of whichrec to determine which
records are on the tape.
If 'segments on tape' variable is located at different offsets within each
segment, you have alot more work. You would have to input from the first
record for five characters at each offset and then have logic to make the
determination of which values at which offset are most likely to represent
the true 'segments on tape' variable.
If the data on the tape when interpreted using different segment 'layout's
causes any fuzziness with regard to determining which segment you are
actually looking at you have even more work to do.
input
@Ps1vA which1 $CHAR5.
@Ps2vB which2 $CHAR5.
@Ps3vC which3 $CHAR5.
@Ps4vD which4 $CHAR5.
@Ps5vE which5 $CHAR5.
;
<logic to determine which value of whichN most likely represents 'segments
on tape'>
whichrec = most likely whichN
The Pass Two macro constructs an input of this form (based on whichrec
value)
input
@PsIv1 sIv1
@PsIv2 sIv2
...
@PsIvN sIvN
@(length of segment I + PsJv1) PsJv1
...
@(length of segment I + PsJvN) PsJvN
@(length of segment I + length of segment J + PsKv1) PsKv1
...
@(length of segment I + length of segment J + PsKvN) PsKvN
...
;
The implementation of the input generating macro is probably greatly
simplified if you place the data dictionary in a SAS data set.
I don't use tapes myself, but if you need to know the total length of a
record (with out knowing which segments are on the record [hence not knowing
the total length of the record]) as part of the information needed to read
the record, I can't be much help.
Q: What's in here ?
A: I don't know.
Q: How long is it?
A: I don't know.
Q: Who does?
A: It does.
Q: Where is it?
A: Right here.
Q: What's in here ?
...
--
Richard DeVenezia
SAS Tips and Tools - http://pweb.netcom.com/~radevenz
"paula" <icj808@uswest.net> wrote in message
news:voB65.684$%O.429790@news.uswest.net...
> My problem, which I hope is exciting, is as follows
>
> I received tapes adding up to 500 variables per record. I am provided with
a
> dictionary, neat and complete, detailing type, length of all the
variables.
>
> The problem is they are grouped into 5 segements, per record. The
dictionary
> agains provides which segement includes which variables. The segements do
> not overlap, that is, each segement has variables that the others do not
> have. Inside each record, it is always one segement lined up after
another.
>
> I have been told that different tapes may have differenct segements
> included. For example, tape one may have segements 1, 2, 5 included, tape
2
> has 3, 4, and tape 3 has 1, 3, 4 and so on. The good news is if a segement
> is determined to be present on a tape, all the variables defined to be
> included in the segement are included.
>
> I have been told there is a field among the variables on each tape that
> tells which segements are on the tape. And that field is a 5 digit
character
> field. It shows up in each record, just like an extra variable. For
example,
> if it reads as A0C00, that means segements 1 and 3 are on the tapes, 0BCD0
> means 2, 3, 4 and so on.
>
> Without accessing this field, I can not know easily the info about the
> segements. But to get to that field, I need to get the segements and all
the
> included fields read in by Input and Infile statements right first. So I
am
> looking for ways to either scan across a record on a tape to know how many
> variables are on it totally, or, supposing I know the name of that
variable,
> scan to read that field without reading in the whole record first.
>
> TIA
>
> Paula D