1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| DATA tarif.test_devis;
INPUT Id_Assure:1. Montant_emp:6. N_ech:3. Tx_per:6.5;
CARDS;
1 350000 360 0.00333 20100101
2 120000 300 0.00404 20100501
3 200000 240 0.00500 20101101
RUN;
DATA tarif.Var1;
SET tarif.test_devis;
CALL SYMPUT(COMPRESS("Montant_emprunte"!!_N_),Montant_emp);
RUN;
DATA tarif.Var2;
SET tarif.test_devis;
CALL SYMPUT(COMPRESS("Nombre_echeances"!!_N_),N_ech);
RUN;
DATA tarif.Var3;
SET tarif.test_devis;
CALL SYMPUT(COMPRESS("Taux_periodique"!!_N_),Tx_per);
RUN;
%MACRO AMORTISSMT(Mt_emprunt,Nb_echeance,Taux_periodiq,tab_amortissement);
DATA TARIF.&tab_amortissement;
Montant_emp=&Mt_emprunt;
N_ech=&Nb_echeance;
Tx_per=&Taux_periodiq;
CRD=Montant_emp;
Interets=CRD*Tx_per;
Capital_remb=Montant_ech-CRD*Tx_per;
Montant_ech=ROUND(Montant_emp*Tx_per*(1+Tx_per)**N_ech/((1+Tx_per)**N_ech-1),0.01);
DO i=1 to N_ech BY 1;
Interets=ROUND(CRD*Tx_per,0.01);
Capital_remb=ROUND(Montant_ech-Interets,0.01);
CRD=ROUND(CRD-Capital_remb,0.01);
OUTPUT;
END;
RUN;
%MEND AMORTISSMT;
%MACRO BOUCLE;
DATA _NULL_;
SET tarif.test_devis END=FIN;
IF FIN THEN CALL SYMPUT('FIN',Id_Assure);
RUN;
%DO j=1 %TO &FIN;
%AMORTISSMT(&&Montant_emprunte&j.,&&Nombre_echeances&j.,&&Taux_periodique&j.,tab_amort&j.);
%END;
%MEND BOUCLE;
%BOUCLE; |
Partager