Hi,
can the below code be written in small and efficient way.basically can we eliminate the repetitive code.
data test2;
set test;
if freq='M' then
do;
date1=canceldate;
days2=intnx('month',date1,1)-intnx('month',date1,0);
if days < days2 then
do;
prem=round(days/days2*prem1,0.01);
calc=round(days/days2*calc1,0.01);
end;
end;
else if freq='H' then
do;
date1=canceldate;
days2=intnx('month',date1,6)-intnx('month',date1,0);
if days < days2 then
do;
prem=round(days/days2*prem1,0.01);
calc=round(days/days2*calc1,0.01);
end;
end;
else if freq='Q' then
do;
date1=canceldate;
days2=intnx('month',date1,3)-intnx('month',date1,0);
if days < days2 then
do;
prem=round(days/days2*prem1,0.01);
calc=round(days/days2*calc1,0.01);
end;
end;
else if freq='F' then
do;
date1=canceldate;
days2=intnx('week',date1,2)-intnx('week',date1,0);
if days < days2 then
do;
prem=round(days/days2*prem1,0.01);
calc=round(days/days2*calc1,0.01);
end;
end;
run;
... View more