It’s all in how you look at it…

I mentioned SAS macros a couple of weeks ago and how I thought they’d be helpful. And they are, tremendously. But I don’t think I understood when we were told, “they’re kind of like function-lite.” It was a little confusing because they have the structure of a function and they seemed to behave mostly like a function. But until I really started digging into them, it didn’t click what was meant by “function-lite.”

SAS macros just don’t have the depth of functions in other languages like Python, R, JavaScript, etc. The more I think about, the more I see that the word macro makes sense as they’re more like the old macros that you could record in MS Office products. They were shortcuts if you found yourself typing the same bits of text over and over. You could just record a macro and assign it shortcut – usually Ctrl+ a letter – and save yourself keystrokes.

Functions are quite a bit deeper and more flexible than just saving keystrokes – though they do that to. Functions can dynamically call other functions based on the input variables – heck another function could be an input variable. I don’t see that as a possibility with SAS macros; though maybe I’ll learn otherwise. But I’m still going to use them quite a bit in SAS as a time and keystroke saver. It wouldn’t make sense not to.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s