LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (June 2000, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 29 Jun 2000 09:10:01 -0400
Reply-To:   Ian Whitlock <WHITLOI1@WESTAT.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Ian Whitlock <WHITLOI1@WESTAT.COM>
Subject:   Re: Scan a record to see what variables are included, without rea ding the data into a dataset
Comments:   To: paula <icj808@USWEST.NET>
Content-Type:   text/plain; charset="iso-8859-1"

Paula,

You have to have an alogrithm for locating the segment indicator. Without it, I think the general problem is unsolvable. With it the problem is easy. Let P denote the position of the field, SEGMENTS. Here are some examples.

P = nnn fixed position input @nnn segments $char5. ;

P = last field on record (LRECL is length from INFILE statement or JCL) input @(lrecl-5) segments $char5. ;

P = third variable of every segment array pos (5) _temporary_ ( ..... ) ; /* fill in with appropriate positions */ cnt = 0 ; do i = 1 to 5 ; input @(pos(i)) segments $char5. @ ; if not verify ( segments , "0ABCDE" ) then do ; p = pos(i) ; cnt + 1 ; end ; end ; if cnt ^= 1 then stop ; input @p segments $char5. ;

If you really don't know the algorithm to find the field, then there are three choices:

1) Ask the creator. 2) Dump 20 records from each tape with the LIST statement and look at them until the algorithm comes to mind. 3) Give the problem to an employee.

If you don't know how to write the program given an algorithm to locate the field, then ask how, after you have given the algorithm.

The problem might be solvable using extra information. Suppose I know that all fields are numeric. Then one could read in 32k characters at a time to locate any of the letters "ABCDE". But then I have just indicated the algorithm for locating the field.

Ian Whitlock <whitloi1@westat.com>

-----Original Message----- From: paula [mailto:icj808@USWEST.NET] Sent: Wednesday, June 28, 2000 9:35 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Scan a record to see what variables are included, without reading the data into a dataset

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


Back to: Top of message | Previous page | Main SAS-L page