BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
GN0001
Barite | Level 11
Hello team, why we are using %include in sas?

What are the options if we don’t want to use it?

Regards
Blueblue
Blue Blue
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

@GN0001 wrote:
Hello team, why we are using %include in sas?

What are the options if we don’t want to use it?

If you don't want to use it, you can set up an AUTOCALL library of macros (if you are talking about macros, you don't really say) and then you don't have to use %include each time you want to use a macro.

 

And if your %include doesn't call in a macro, you could make it a macro.

 

Please see this thread for more details on the benefits of AUTOCALL compared to %include

https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Help-Text-Documentation/m-p/753876#M237672

--
Paige Miller

View solution in original post

6 REPLIES 6
ballardw
Super User

%include is used to submit code stored in an external file.

 

Why? Many reasons are possible. One is that the code has been well debugged and doesn't need changes. So move to an external file so your current editor window isn't clogged up. Another just plain log code that doesn't change such as a bunch of format definitions.

Another use so that multiple users can access the code in the same file and inherit any changes made without rewriting code (cautions apply to other dependencies).

 

GN0001
Barite | Level 11
Thanks fir the response. Is it recommended to use?
Blueblue
Blue Blue
ballardw
Super User

@GN0001 wrote:
Thanks fir the response. Is it recommended to use?
Blueblue

If the examples I provided, or similar ideas, apply then yes. %include is a very mature tool been around in SAS coding since at least the 1980's.

PaigeMiller
Diamond | Level 26

@GN0001 wrote:
Thanks fir the response. Is it recommended to use?
Blueblue

Any supported feature of SAS (and this is supported) is "recommended to use".

 

Whether or not it is a good idea to use it, or whether or not there are easier ways to do what you want, depends on a lot of things, including your situation and reason for using %include, which you have not explained.

--
Paige Miller
SASKiwi
PROC Star

Why we are using %include in sas?

To read in and run SAS code stored in another program file into the program with the %include statement.

 

What are the options if we don’t want to use it?

Copy the code that is in the other program and add it to the current program. The downside is you end up duplicating code all over your programs creating a potential  maintenance problem.

PaigeMiller
Diamond | Level 26

@GN0001 wrote:
Hello team, why we are using %include in sas?

What are the options if we don’t want to use it?

If you don't want to use it, you can set up an AUTOCALL library of macros (if you are talking about macros, you don't really say) and then you don't have to use %include each time you want to use a macro.

 

And if your %include doesn't call in a macro, you could make it a macro.

 

Please see this thread for more details on the benefits of AUTOCALL compared to %include

https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Help-Text-Documentation/m-p/753876#M237672

--
Paige Miller

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1932 views
  • 5 likes
  • 4 in conversation