First, the very first line of a function or macro, that defines it as a function/macro, is very similar. In Python, one would write:
def buildConnectionString(params):
In SAS, it is very similar:
%macro buildConnectionString(params);
The terms def and %macro begin the code by stating what follow: a function definition or a macro. The "buildConnectionString" is the name of the function/macro, and enclosed in parentheses are the function/macro parameters or arguments, separated by commas.
Second, it is often a good idea to have some documentation on the function/macro. In Python, the documentation is stored in a doc string; in SAS, a very short and not as useful description string is available:
def buildConnectionString(params):
"""Build a connection string from a dictionary of parameters.
Returns a string."""
SAS:
%macro buildConnectionString(params) / des="Build connection string. Returns string.";
UPDATE: I'm not sure where I learned the 40-character limit mentioned below, but I just read in the SAS help documentation that the limit is 256 characters. Nonetheless, reading the description is still limited by screen space, so the alternatives I mentioned here are still very useful.
Unfortunately, SAS macros are limited to
One area of difference is the syntax and the meaning of space: In all Python code, space has meaning, whereas in SAS code in general, it does not. Even so, I typically indent my SAS code just like Python code requires (in most cases - I try to maintain readability, too).
Once I learn more about Python, I'll post more comparisons!
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.