Joined: 19 Aug 2005 Posts: 17 Location: Chennai, India
Hi,
My requirement is as below
I have the input flle which will have Policy Id(12bytes)
Another Input file which will have Policy Id Range(Start and End)
I need to read the both files and write into two output files based on If the policy id fall in the range then write into Inrange file and If not then write into Out of range.
Is anybody help me can we do this through sort or other utilities other than cobol.
Nanda
Joined: 06 Jun 2008 Posts: 8696 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.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Nanda,
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)
Exp:
Start Range End Range(In between One Filler)
221010000992 221010520999
221010522995 221010586990
Output Requirements:
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.
DATA TESTDATA;
INFILE ITEST END=EOF;
INPUT @001 POLINLOW $CHAR12.
@014 POLINHIG $CHAR12.;
OUTPUT;
RUN;
PROC SQL;
CREATE TABLE DADFAM1 AS
SELECT *
FROM PRODDATA , TESTDATA
WHERE POLINO >= POLINLOW AND POLINO <= POLINHIG
ORDER BY POLINO;
QUIT;
PROC PRINT DATA=DADFAM1;RUN;
PROC SORT DATA=DADFAM1;BY POLINO;RUN;
PROC SORT DATA=PRODDATA;BY POLINO;RUN;
DATA NOMATCH;
MERGE PRODDATA(IN=A)
DADFAM1(IN=B);BY POLINO;
IF A AND NOT B THEN OUTPUT;
RETURN;
RUN;
PROC PRINT DATA=NOMATCH;RUN;
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
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.