Joined: 06 Jun 2008 Posts: 8218 Location: Dubuque, Iowa, USA
How many policy numbers? How many policy ranges?
Depending upon the number of policy ranges, you could write a SAS program that generates SAS code to create a format for the policy ranges with an OTHER value. Read the first file, do a X = PUT(policy_number, policy_format.) ; and if X is whatever value you assigned to OTHER then write to out of range file, else write to inrange file.
So your job would be two steps of SAS code; the first step generates the PROC FORMAT statements into a temporary file. The second step reads as input the temporary file followed by your code to process the policy number file.
If you want a DFSORT solution, you need to supply more information because your requirement is not clear.
Please show an example of the records in each input file (relevant fields only) and what you expect for output. Explain the "rules" for getting from input to output. Give the starting position, length and format of each relevant field. Give the RECFM and LRECL of the input files. If file1 can have duplicates within it, show that in your example. If file2 can have duplicates within it, show that in your example.
Input File2:Contains 6 records(FM:FB,RECL:30Bytes)
Start Range End Range(In between One Filler)
We need to read each Policy id from Input file1 and check if that Policy id fall under any one of the range in the Input file2.If its falls then we need to write that Policy id into Range file and If not then we need write into Not range file.
INFILE ITEST END=EOF;
INPUT @001 POLINLOW $CHAR12.
@014 POLINHIG $CHAR12.;
CREATE TABLE DADFAM1 AS
FROM PRODDATA , TESTDATA
WHERE POLINO >= POLINLOW AND POLINO <= POLINHIG
ORDER BY POLINO;
PROC PRINT DATA=DADFAM1;RUN;
PROC SORT DATA=DADFAM1;BY POLINO;RUN;
PROC SORT DATA=PRODDATA;BY POLINO;RUN;
IF A AND NOT B THEN OUTPUT;
PROC PRINT DATA=NOMATCH;RUN;
If it can have more than 6 records, then another approach would be needed (I posted the simplest solution based on the assumption that you only had 6 records). Since you have a SAS solution that works, I won't bother posting a solution for n records.