Help using Base SAS procedures

Table Lookup returns "Not Found" if processing the same key in a row checking _IORC_

Accepted Solution Solved
Reply
Contributor
Posts: 23
Accepted Solution

Table Lookup returns "Not Found" if processing the same key in a row checking _IORC_

I load a table to do lookups but if I search the table with a key that was just found, I get a not found _IORC_ returned. Do I need to reset something before my next lookup?

LOOKUP KEY = 22 KEY1=ABCTA

PREFIX     = 22 PREFIX=D

MATCH GOOD = 22 KEY1=ABCTA

LOOKUP KEY = 23 KEY1=ABCTA

PREFIX     = 23 PREFIX=D

NO MATCH FOR = 23 KEY1=ABCTA

Example:

DATA LOOKUP(INDEX=(KEY1));

INFILE LOOKUP END=EOFIND1;

    INPUT @1  KEY1    $08.

  @10 OUTID $03.;

RUN;

KEY1 = 'ABCTA';

SET LOOKUP KEY=KEY1;

  

/* CHECK RETURN CODE FROM SEARCH */

SELECT (_IORC_);

  /* MATCH FOUND */

  WHEN (%SYSRC(_SOK)) DO;

    PUTLOG 'MATCH GOOD = ' _N_ KEY1=;

    FILE GOOD;

    PUT @1  KEY1

          @10 STUFF;

  END;

  /* MATCH NOT FOUND IN MASTER */

  WHEN (%SYSRC(_DSENOM)) DO;

    _ERROR_=0;

    /* RESET VALUES IN PDV FROM LAST MATCHED CONDITION */

    PUTLOG 'NO MATCH FOR = ' _N_ KEY1=;

END;


Accepted Solutions
Solution
‎03-31-2015 02:51 AM
SAS Employee
Posts: 340

Re: Table Lookup returns "Not Found" if processing the same key in a row checking _IORC_

SET LOOKUP KEY=KEY1  /unique;

View solution in original post


All Replies
Solution
‎03-31-2015 02:51 AM
SAS Employee
Posts: 340

Re: Table Lookup returns "Not Found" if processing the same key in a row checking _IORC_

SET LOOKUP KEY=KEY1  /unique;

Contributor
Posts: 23

Re: Table Lookup returns "Not Found" if processing the same key in a row checking _IORC_

Posted in reply to gergely_batho

Thank you for the feedback - I ended up using the KEYRESET= not totally clear on each option

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 161 views
  • 0 likes
  • 2 in conversation