I'm reading in a file and doing some checks on it before processing it. and I'm reading in my header record on line one and then going to line two to read in another var. Now once I have my second var from line two, how can I tell sas in the input statement to go back to line 1 again to get my third value?
My file consist of the first rec being the HEADER, it also has the File Creation date on this line. Next line (line 2) is were my detail record starts, with actual ppl data. and each row that starts with a "02" is a valid record. the number of detail records vary from file to file. next after all the detail records the last rec is a Trailer record. Now I'm doing these checks because we apparently have some invalid files on our system, and don't want to process them.
The problem I am having is
- first I'm checking to make sure the file is valid by make sur ethe first record is indeed a HEADER row
-second I'm checking, "02" row for detail records. By say ok if your first row is a HEADER and your 2nd row starts with a "02" then your mored than likely a valid file , and **heres where my code isn't working. I then want it to go back to record 1 and now pull the File Creation date.**
If anyone knows out to make the pointer go back in a INPUT statement plz help me out, Thanks.
Code:
DATA GOOD NOTVALID;
INFILE SASI1 END = NODATA;
BADGDG = %ADDTICKS(%FILEDATA(SASI1,1));
INPUT @01 CHECK1 $CHAR6.@;
IF (CHECK1 = 'HEADER' AND _N_ ¬= 1) OR (CHECK1 ¬= 'HEADER' AND
_N_ =1 ) THEN DO;
FLG='BADFILE';
OUTPUT NOTVALID;
END;
ELSE IF CHECK1='HEADER' AND _N_ =1 THEN DO;
INPUT / @01 REC02 $CHAR02.@;
IF REC02 ¬= '02' THEN DO;
FLG='BADFILE';
OUTPUT NOTVALID;
END;
END;
IF FLG ¬='BADFILE' THEN DO;
RETAIN FILEDT;
INPUT @01 CHECK1 $CHAR6.
@07 FILEDT YYMMDD08.@;
IF CHECK1='HEADER' THEN DO;
CREDAT = FILEDT;
END;