From the course: SAS Programming for R Users, Part 2

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Creating macro programs with parameters

Creating macro programs with parameters - SAS Tutorial

From the course: SAS Programming for R Users, Part 2

Creating macro programs with parameters

- [Narrator] Now just like in R, we can pass macro a parameter list to customize the program even further. And just like in R we can use positional keyword or a mixture of those parameter lists. Now in R you probably don't know the exact names. You've probably just bypassed that part, but in SAS there's just little bit more structure so we need to be a little bit more aware of what position and keyword parameter is. So here I'm creating a macro called calc, and you'll notice it's just the mean's procedure. And I have two positional parameters, a dsn, for data set name, separated by comma, and vars, for the variables that I'm going to put in my var statement. And you'll notice when I pass in those parameters I'm passing them in as if they are macro variables. So I'm tacking on an ampersand to dsn and vars in the means procedure. So when I go ahead and call the macro with %calc, I'll simply list the data set name, in this case, business, and the variables, in this case, just yield. Why…

Contents