6. Database Tailoring and Retrofitting Techniques › 6.3 Retrofitting Guidelines › 6.3.1 Correcting a File After Creation › 6.3.1.3 Correcting Timespans and Cycles
6.3.1.3 Correcting Timespans and Cycles
The prior section showed how to correct a problem in a single
file's DETAIL timespan. If a problem existed in several
timespans and in multiple cycles in each timespan, then all
cycles in all affected timespans need a DATA step like the
one shown in the prior section to treat the bad value.
Rather than coding one DATA step for each cycle of the file
in each timespan affected, consider using SAS macros to
provide substitutable code.
The macro method is relatively easy to use and test. It
lends itself to applications where fewer cycles of each
timespan are affected. The principle is to make a macro of
the DATA statement, with substitutable DDname and file/cycle
names, and execute the DATA step a number of times.
The correction logic macro might look like this:
%MACRO RETFIT(DDN,FN,FFF,TS);
DATA &DDN..&FN (%&FFF.FILE(OP=FILEOPTS,TS=&TS));
SET &DDN..&FN;
(correction logic)
RUN;
%MEND RETFIT;
It could be called from a sequence such as:
%RETFIT(&TNPAX,NPANCP01,NCP,DETAIL)
%RETFIT(&TNPAX,NPANCP02,NCP,DETAIL)
%RETFIT(&TNPAX,NPANCP03,NCP,DETAIL)
...
%RETFIT(&TNPAX,NPANCPnn,NCP,DETAIL)
%RETFIT(&TNPAD,NPANCP01,NCP,DAYS)
%RETFIT(&TNPAD,NPANCP02,NCP,DAYS)
%RETFIT(&TNPAD,NPANCP03,NCP,DAYS)
...
%RETFIT(&TNPAD,NPANCPnn,NCP,DAYS)
...