What is the best way to transport a macro across projects in SAS Enterprise Guide?
I know you can write an %include statement, but this seems to require saving a files as .sas instead of .egp. I was wondering if there was a more efficient way to do this in SAS EG?
Thanks,
Bill
Assuming these macros are all general and you don't change them through projects I recommend setting up a macro library.
Note that I will also store all the macro's in a single utility folder as .sas files. .egp files are propietary and can have issues over time. .sas files are text files. But for day to day usage of common macros, a macro library is a good idea. And make sure to use the SOURCE option on your macros so you can retrieve the code if you ever lose track of your .sas programs.
https://support.sas.com/resources/papers/proceedings/pdfs/sgf2008/101-2008.pdf
https://www.listendata.com/2016/04/building-sas-macro-library.html
https://pauldickman.com/sastips/autocall/
@whs278 wrote:
What is the best way to transport a macro across projects in SAS Enterprise Guide?
I know you can write an %include statement, but this seems to require saving a files as .sas instead of .egp. I was wondering if there was a more efficient way to do this in SAS EG?
Thanks,
Bill
THE PROPER WAY OF STORING SAS CODE IS AS TEXT IN .sas FILES.
Write this a hundred times, or until you have internalized it.
I mean it, from 20+ years of SAS experience and 40 years in IT.
That is a good question and hope some EG developers ( @ChrisHemedinger ) .
Traditionally with SAS project code we would create a macro library and maintain the code there and use SASAUTOS to have SAS automatically find and compile any macros that a specific program calls. I have not seen a good method of building such a system for EG files ("projects"). To me the EG files feel more like Excel spreadsheets. A nice way to build something but not something that has a pathway to a real production environment.
Assuming these macros are all general and you don't change them through projects I recommend setting up a macro library.
Note that I will also store all the macro's in a single utility folder as .sas files. .egp files are propietary and can have issues over time. .sas files are text files. But for day to day usage of common macros, a macro library is a good idea. And make sure to use the SOURCE option on your macros so you can retrieve the code if you ever lose track of your .sas programs.
https://support.sas.com/resources/papers/proceedings/pdfs/sgf2008/101-2008.pdf
https://www.listendata.com/2016/04/building-sas-macro-library.html
https://pauldickman.com/sastips/autocall/
@whs278 wrote:
What is the best way to transport a macro across projects in SAS Enterprise Guide?
I know you can write an %include statement, but this seems to require saving a files as .sas instead of .egp. I was wondering if there was a more efficient way to do this in SAS EG?
Thanks,
Bill
Hi @whs278
Consider building a SAS package. Check out: https://github.com/yabwon/SAS_PACKAGES there is a pdf article from SGF2020 describing the process.
All the best
Bart
Thank you for sharing @yabwon 👍
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.