using %include statement

Reply
Contributor
Posts: 46

using %include statement

Hi,

I'm trying to store all my libraries in one %includes statement, I did that before but unable to think how I did that.

 

Here is an example of my libraries in sas 9.4.

 

libname A "C:\\desktop\toys";

libname B "C:\\desktop\price";

libname C "C:\\desktop\orders";

 

I want to put all these libraries in %include so that I can just use one %include statement in my programs to access all these libraries instead of mentioning all the libraries again in the program.

 

Can anyone help me in this? I know it is  very simple and easy but unable to figure out how I did before.

 

Thanks

M

Super User
Posts: 19,167

Re: using %include statement

Create a SAS program that contains all your library definitions.

 

Then use %include to that program whenever you want to assign all libraries.

 

If you're looking for this to occur automatically when you start SAS you need to modify your autoexec or config file. Usually you'll have access to an Autoexec but not necessarily the config file. 

Contributor
Posts: 46

Re: using %include statement

Thank you Reeza, I figured out using %include immediately after posting it. Thank you for the automatic running of %include which I'll try and see if I can get it as I like the idea of making it run automatically when I start SAS.

 

Thanks

M

Valued Guide
Posts: 2,177

Re: using %include statement

there is a concept referred to as AUTOEXEC.
There you can store statements that will execute when SAS starts
Contributor
Posts: 46

Re: using %include statement

Hi Peter,

can you provide me an example for autoexe. Do we have to make it a global option in the sas program and run it?

 

Thanks

M

PROC Star
Posts: 7,437

Re: using %include statement

@Malathi13: It's just a txt file that contains SAS statements.  See: http://support.sas.com/kb/19/244.html

 

HTH,

Art, CEO, AnalystFinder.com

 

Respected Advisor
Posts: 4,137

Re: using %include statement

Whatever you add to an autoexec will get executed during SAS startup and will be applicable always.

 

For library assignments: You can do this in an autoexec but I'm kind of astonished that no one mentioned to do such an assignment via SAS Metadata Server (using SAS Management Console) as that's the place where this normally is done in a corporate environment.

Using SAS Metadata also allows you to only get such assignments executed for certain metadata groups (ie. a department) and not the whole company.

 

Managing such company level SAS configurations is a SAS Administrator task. Contact yours if you've got such requirements.

Ask a Question
Discussion stats
  • 6 replies
  • 156 views
  • 0 likes
  • 5 in conversation