I have a requirement to add the total number of records in the input file (Including Header and Trailer) and update the Trailer-Record-Count (PIC 9(09) Field in the trailer record.
And also all the records needs to be copied to output as it is.
For test I have taken One Header, One Trailer and One detail record.
The Code Is as given below:
Code:
DATA INTEST;
INFILE INFILE ;
INPUT @1 RECTYPE $CHAR1. ;
IF (RECTYPE = 'H') THEN
DO;
COUNT = 1;
FILE OUTFILE;
PUT _INFILE_;
END;
IF (RECTYPE = 'D') THEN
DO;
COUNT = COUNT + 1;
FILE OUTFILE;
PUT _INFILE_;
END;
IF (RECTYPE = 'T') THEN
DO;
FILE OUTFILE;
PUT @1 'T'
@2 COUNT ZD 9;
END;
PROC PRINT DATA = INTEST(OBS=3);
RUN;
But the COUNT Field is not displaying the count properly. The COUNT = 1 is proper, but when I add +1 to it, the data is not proper.
Hi Sharath,
I bet there was a message in your output along these lines
Code:
NOTE: Missing values were generated as a result of performing an operation on mi
Each place is given by: (Number of times) at (Line):(Column).
1 at 12:17
a automatic variable for finding the no. of records read from the input file...Since you know that there will be a header and trailer in ur input file, just subtract 2 from it at the end and update the trailer record.