BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
NKormanik
Barite | Level 11

I'm surprised to see all the non-answers in documentation and posts regarding a simple question:

 

Where to store your macros??

 

Lots of good macros out there, maybe hundreds, thousands.  Suppose we collect a fair number of them.  And, maybe even write a few... or one.  (so far I'm at zero)

 

Well, where best to keep all those macros?.  (Assume Windows computer.)

 

How about:  "D:\SAS Macros\"

 

And, follow-up.  How then do we access one of those macros we've saved?

 

Thoughts greatly appreciated.

 

Thanks,

Nicholas Kormanik

 

 

 

 
 
1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

There are a few ways to do this. The three ways that I usually mention are:

 

  1. Using one or more %include statements to point to your macro definitions. The least sophisticated method and not recommended.
  2. Using the Stored Compiled Macro Facility.
  3. Using the Macro Autocall Facility.

 

This is the topic of chapter 10 in Carpenter's Complete Guide to the SAS® Macro Language by @ArtC. Highly recommendable.

 

Hope this helps 🙂

View solution in original post

12 REPLIES 12
PeterClemmensen
Tourmaline | Level 20

There are a few ways to do this. The three ways that I usually mention are:

 

  1. Using one or more %include statements to point to your macro definitions. The least sophisticated method and not recommended.
  2. Using the Stored Compiled Macro Facility.
  3. Using the Macro Autocall Facility.

 

This is the topic of chapter 10 in Carpenter's Complete Guide to the SAS® Macro Language by @ArtC. Highly recommendable.

 

Hope this helps 🙂

ballardw
Super User

Another support for the Macro autocall facility.

 

Know where your code is, compiles the macros when needed/used.

Kurt_Bremser
Super User

And, with the autocall facility, you keep your macros stored in .sas text files, preventing any troubles with SAS catalogs when you move to a different environment or upgrade SAS.

PaigeMiller
Diamond | Level 26

One more vote in favor of the AutoCall library.

 

In fact, since my Autocall library is on a server, other people in my department can access all my macros simply by including my Autocall folder in their SASAUTOS option. And I can use their macros the same way, by putting their autocall folder into my SASAUTOS. This way, if any of us add a feature or fix a bug in one of those macros, everyone gets the new feature or new bug fix immediately.

 

Unfortunately, at this time, this feature doesn't work across departments, people who might want to use my macros but don't have read access to the server I use can't use the macros I have written. (But, there's not a huge demand for this right now)

--
Paige Miller
Reeza
Super User
I'm going against the grain, mostly because I don't program daily in SAS anymore. I store my files on Github/Git and use a variation of %INCLUDE to pull the code from Github/Git in the programs needed.

If I was programming daily and had tasks that made sense to share with my colleagues and only had usage within my work then I'd likely use an Autocall library as well.
PaigeMiller
Diamond | Level 26

@Reeza I know you use Github a lot, and I never have used it. What are the advantages and disadvantages of storing macros on Github?

--
Paige Miller
Reeza
Super User
Mostly that my programs can run from anywhere - SAS Studio On Demand, SAS UE, a custom installation. Other side benefits, it's easy to share with others, there's automatic version control, GIthub search is good when I'm searching for a particular macro and if so inclined, you can allow others to modify, change or update programs if they find bugs or have improvement suggestions.

I have a tendency to change jobs often (2 to 3 years) so its also nice to not have to worry about recreating all my general reporting macros each time I change positions.
PaigeMiller
Diamond | Level 26

I suppose you cannot point the SASAUTOs option to the Github "folder" or whatever it is. Otherwise, you have to %include the desired macros in a SAS session. In my case, the way I write code, one macro calls several other macros (and I don't recall off the top of my head which macro calls which other macros), it seems as if Github isn't the solution for me, other than perhaps if I tended to move to new jobs regularly (which I don't).

--
Paige Miller
Reeza
Super User
The newer versions of SAS have repository support so that Github and Git are synced so in theory you should have copies locally accessible as well or access easily. I would assume that means you have access within SASAutos but not way to test it.
ballardw
Super User

Fun things like my current employer completely blocks Github and almost any "file sharing" site of any flavor. So I can't really even test the pros and cons involved.

Reeza
Super User
Yeah, we still don't allow cloud tools either and it drives me insane. We used to have similar locks but I think when we went to Work From Home, they finally lifted them.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 12 replies
  • 967 views
  • 14 likes
  • 6 in conversation