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
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
[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.
@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
whichrec = most likely whichN
The Pass Two macro constructs an input of this form (based on whichrec
@(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 ?
SAS Tips and Tools - http://pweb.netcom.com/~radevenz
"paula" <firstname.lastname@example.org> wrote in message
> My problem, which I hope is exciting, is as follows
> I received tapes adding up to 500 variables per record. I am provided with
> dictionary, neat and complete, detailing type, length of all the
> The problem is they are grouped into 5 segements, per record. The
> 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
> I have been told that different tapes may have differenct segements
> included. For example, tape one may have segements 1, 2, 5 included, tape
> 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
> field. It shows up in each record, just like an extra variable. For
> 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
> included fields read in by Input and Infile statements right first. So I
> 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
> scan to read that field without reading in the whole record first.
> Paula D