I have the following piece of SAS code worked and gave me 34 rows of records returned as expected.
DATA IRSLOAD.IRSLOAD(KEEP = IRS_CRN, IRS_REVRSN, IRS_PAY, IRS_REG, IRS_METH, ENV, IRS_PTNRPID, IRS_LINKNO, IRS_PTNRKWD, IRS_LINKRSN, IRS_AREA, RANDOM);
SET IRSLOAD.IRSLOAD;
RETAIN I 1;
IF IRS_PAY='FTB' THEN DO;
IF I LE 34 AND IRS_AREA = ('AS1')
THEN DO;
IRS_METH = 'PHO';
OUTPUT IRSLOAD.IRSLOAD;
I = I + 1;
END;
RETURN;
And then I rewrote it as a macro being called by SAS, I have 5315 rows in return and have no IRS_METH written as 'PHO' and as if the output data is exactly the same as the input. Can anyone give me some advice?
%MACRO SEL(IRS_AREA,NUM);
%LET I = 1;
%IF &I LE NUM AND &IRS_AREA=IRS_AREA
%THEN %DO;
IRS_METH = 'PHO';
OUTPUT IRSLOAD.IRSLOAD;
&I = &I + 1;
%END;
%MEND SEL;
DATA IRSLOAD.IRSLOAD(KEEP = IRS_CRN, IRS_REVRSN, IRS_PAY, IRS_REG, IRS_METH, ENV, IRS_PTNRPID, IRS_LINKNO, IRS_PTNRKWD, IRS_LINKRSN, IRS_AREA, RANDOM);
SET IRSLOAD.IRSLOAD;
IF IRS_PAY='FTB' THEN DO;
%SEL(AS1,34);
END;
RETURN;
Thank you cynthia : )
Message was edited by: willow2010
... View more