Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How To Find First Record of Input Data

Status
Not open for further replies.

ks01

MIS
Aug 11, 2002
110
US
Hi everyone ... I would appreciate some input on the best way to accomplish my objective. Here is a bit about my situation. Our shop runs SAS version 9.1 on z/OS.

I have an 80-byte raw data set which contains anywhere from 60,000,000 to 70,000,000 records. This raw data set is a list of account numbers currently open (with other attributes) and is created once a week. The account number records in this data set is sorted by acocunt number in ascending order.

I know that the account number I am interested in will be located close to the top of my input data set. What I would like to do is one of two things:

1. When SAS finds the account number from the file, stop reading the rest of the input file.
2. If SAS reaches a range of data that is higher than my account number, stop reading the rest of the input file.

I would like the second criteria in case the account number I am intersted does not exist in the data set, there is no reason to continue reading records.

Here is a sample of my input data:

[tt]124000000000000001 04Ø.011000000000000000 071008EDE3..429072427207E A>®
124012300000000002 41..010000000000000100 080605FVE5..400011400145FVEN{..
124452600000000003 41..010000000000000100 090605FVE5..433322400145FVEN{..[/tt]

I have 59 of these files to search so there will be an enormous amount of searching going on.

Here is the code I'm using to find my search criteria, but I am not sure how to go about implementing the two options I want.

Code:
  OPTIONS NOSOURCE;
  DATA R001 (KEEP= ISSUENUM SATEFFDT LSTGDATA ACCTBIN ACTNCD REGNSUMM
                   PRGEDT);
  INFILE INPUT1;
  FILE OUTPUT1;
  RETAIN SATEFFDT;

  IF _N_ = 1 THEN
    PUT @01  'KEY'
        @21  'BIT FLAGS'
        @38  'AC'
        @41  'DLM'
        @52  'DPLM' ;

  INPUT @01 RECTYP $CHAR1. @ ;
    IF RECTYP = '0' THEN
          INPUT @09 ISSUENUM $CHAR2.
                @12 SATEFFDT MMDDYY6. ;

    IF RECTYP = '1' THEN
      DO;
        INPUT @03 LSTGDATA $CHAR16.
              @03 ACCTBIN  $CHAR6.
              @22 ACTNCD   $CHAR2.
              @28 REGNSUMM $CHAR16.
              @28 REGION0  $CHAR1.
              @29 REGION1  $CHAR1.
              @30 REGION2  $CHAR1.
              @31 REGION3  $CHAR1.
              @32 REGION4  $CHAR1.
              @33 REGION5  $CHAR1.
              @34 REGION6  $CHAR1.
              @35 REGION7  $CHAR1.
              @36 REGION8  $CHAR1.
              @37 REGION9  $CHAR1.
              @38 REGIONA  $CHAR1.
              @39 REGIONB  $CHAR1.
              @40 REGIONC  $CHAR1.
              @41 REGIOND  $CHAR1.
              @42 REGIONE  $CHAR1.
              @43 REGIONF  $CHAR1.
              @45 PRGEDT   YYMMDD6. ;

        IF REGION0 = '0' THEN REGION0 = ''; ELSE REGION0 = '0';
        IF REGION1 = '0' THEN REGION1 = ''; ELSE REGION1 = '1';
        IF REGION2 = '0' THEN REGION2 = ''; ELSE REGION2 = '2';
        IF REGION3 = '0' THEN REGION3 = ''; ELSE REGION3 = '3';
        IF REGION4 = '0' THEN REGION4 = ''; ELSE REGION4 = '4';
        IF REGION5 = '0' THEN REGION5 = ''; ELSE REGION5 = '5';
        IF REGION6 = '0' THEN REGION6 = ''; ELSE REGION6 = '6';
        IF REGION7 = '0' THEN REGION7 = ''; ELSE REGION7 = '7';
        IF REGION8 = '0' THEN REGION8 = ''; ELSE REGION8 = '8';
        IF REGION9 = '0' THEN REGION9 = ''; ELSE REGION9 = '9';
        IF REGIONA = '0' THEN REGIONA = ''; ELSE REGIONA = 'A';
        IF REGIONB = '0' THEN REGIONB = ''; ELSE REGIONB = 'B';
        IF REGIONC = '0' THEN REGIONC = ''; ELSE REGIONC = 'C';
        IF REGIOND = '0' THEN REGIOND = ''; ELSE REGIOND = 'D';
        IF REGIONE = '0' THEN REGIONE = ''; ELSE REGIONE = 'E';
        IF REGIONF = '0' THEN REGIONF = ''; ELSE REGIONF = 'F';

        IF LSTGDATA = '4012300000000003';

        PUT @01 LSTGDATA
            @21 REGION0
            @22 REGION1
            @23 REGION2
            @24 REGION3
            @25 REGION4
            @26 REGION5
            @27 REGION6
            @28 REGION7
            @29 REGION8
            @30 REGION9
            @31 REGIONA
            @32 REGIONB
            @33 REGIONC
            @34 REGIOND
            @35 REGIONE
            @36 REGIONF
            @38 ACTNCD
            @41 PRGEDT   YYMMDD10.
            @52 SATEFFDT YYMMDD10.;
      END;

RUN;

Thanks in advance ... I look forward to hearing your suggestions!

Kent
 
I do not have a RAW file to test on, but why not use the STOP or ABORT statement? You can set some conditions to test and then call the STOP statement. This will stop the current datastep (your search in one file) and let your program continue to open and start reading in another data source.

I hope this helps.

Klaz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top