05-21-2012 10:50 PM
I wrote the above ,trying to include all macros under the directory, but failed.
How to modifiy those code?
05-21-2012 11:07 PM
05-21-2012 11:18 PM
filepad was red
log is somewhat like invalid statement or not using in correct sequence.
(SAS version not an english version)
04-09-2013 08:38 AM
Elegant and to the point. Will make it easy for my purposes. With larger projects, I like to have several .sas files with specific purposes. Any idea on whether this would cause additional .sas files in subfolders to be included?
01-09-2013 10:54 PM
It's possible you found a way by now, but consider that it might not be the correct thing to do. If you want all the macros in the folder available for use, you don't have to %include them. Another approach:
You can also specify more than one folder using this method.
01-09-2013 11:17 PM
The problem with the sasautos option is that it must be invoked when SAS is started. This means that a user who does not include the option when they start SAS must find some other way to compile the macros. It can be very confusing if you are trying to debug someone else's program that works perfectly for them because their code may not include any reference to where the macros are located.
So I would only advocate use of sasautos under very tight controls where all users have it activated and the directories are read only (because one user's mod of a macro would require integration testing of all other SAS code which might make use of the macro).
01-10-2013 09:18 AM
I'm not sure which method would be simpler. I could imagine a user of either method being dumbfounded by being asked where his macro is stored. In fact, I've even seen one experienced programmer who stored 40 macros in a single file so he could %include just that one file. If you're going to %include all of your macro definitions, that makes as much sense as any.
Note that sasautos doesn't have to be specified at SAS invocation. The options statement can appear within a SAS program.
01-10-2013 03:23 PM
Aha, that change to sasautos system option snuck up on me. Makes it more usable.
I still prefer individual %include statements for each macro file, because that states explicitly at th head of a script, where each macro is located.
04-09-2013 12:10 PM
I have had many discussions with other SAS-L peers over the years about this idea of
%including user-written macros before they are called.
keep the log short: do not %include
SAS does the %include for you via the option sasautos.
commentary: isn't mprint enough for you to see the code generated?
Ron Fehd SASautos maven
01-10-2013 08:11 AM
May be this can be useful for your task... Its a bit complicated but can be used as a macro application.
Assuming your single folder have all program that you want to call using %include....
Here is the program
Note: This macro take the full name of all file in a folder ending with .sas .
Create a series of macro variable with file name .
Resolve the value of each SAS file in %include statement using %do loop in macro.
filename filelist pipe "dir /b /s &dir\*.sas";
infile filelist truncover end=last;
input filename $100.;
call symputx('mac1'||left(_n_) , strip(filename));
if last then call symputx('nobs' , _n_);
%do i =1 %to &nobs;
Hope it will help.....
01-10-2013 08:18 AM
More simple program may be...
filename filelist pipe "dir /b /s &path\*.sas";
infile filelist truncover;
input filename $100.;
call execute(cats('%include ',quote(trim(filename)), ';'));