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

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

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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




View solution in original post

7 REPLIES 7
Kurt_Bremser
Super User

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.

novinosrin
Tourmaline | Level 20

"I mean it, from 20+ years of SAS experience and 40 years in IT."- Kudos! and my sincere salutations. I guess that's right up there among the likes of @art297  and @Tom  Well done!

Tom
Super User Tom
Super User

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.

Reeza
Super User

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




yabwon
Onyx | Level 15

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 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



yabwon
Onyx | Level 15
@novinosrin - enjoy!
Read it, try it, build a package! 🙂 🙂

All the best
Bart
_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 7 replies
  • 898 views
  • 6 likes
  • 6 in conversation