The SUBROUTINE statement
names the block of code that is processed and specifies the parameters.
The OUTARGS statement specifies the parameters that the subroutine
updates. The ENDSUB statement ends the definition of the subroutine.
In the following example, the subroutine CALC_YEARS is defined to
calculate years to maturity from SAS date variables:
subroutine calc_years(maturity, current_date, years);
outargs years;
years=(maturity - current_date) / 365.25;
endsub;
The following code is
an example of calling the CALC_YEARS subroutine:
data _null_;
myCD='23jul2017'd;
now=today();
how_many_years=.;
call calc_years(myCD,now,how_many_years);
put how_many_years=;
run;
The following table lists the differences ...