06-24-2016 08:06 PM
For functions you want Proc FCMP.
Macros don't return values.
You can call a macro within any other macro once it's been compiled.
If your replicating R code you can consider SAS/IML instead of Base.
Otherwise you may want to define your functionality and figure out the best method in SAS. Trying to replicate exactly is more work in long run. My nickel.
06-25-2016 02:52 AM
06-25-2016 04:46 AM
Yes you can.
In the same session you can do stuff like this:
%macro outer; %put In outer; %inner %mend %macro inner; %put In inner %mend; %outer;
The inner macro needs to be defined at call time, not nescecarily when %Outer is defined. And %inner can be redefined without the need for %outer to be recompiled.
Existing macros can also be defined earlier or outside SAS. Store them in a file with the .sas extension and have the SASAUTOS option point to its location.
As @Reeza pointed out, macro's do not technically return a value like a function does. But it is conceptually close enough. Just look at the %SYSRC autocall macro for a nice example.
Hope this helps,