Hi,
I have a some macros, say, A to E, executed in that order (A calls B, C, D and E). Each macro is in a separate .SAS file(say, Macro A is in A.sas, B in B.sas and so on). The parameters passed to the macros and those used in the macros are stored in a SAS dataset (central table).
I am trying to write a UNIX shell script that compiles the macros at run time as Stored Compiled Macros (I included the /STORE syntax in macros) and executes them.
My shell script:
#!/bin/bash
sas -AUTOEXEC "/sasdata/autoexec/project_autoexec.sas" A.sas B.sas C.sas D.sas E.sas.
I also tried using separate lines for each .sas file.
sas -AUTOEXEC "/sasdata/autoexec/project_autoexec.sas" A.sas
sas B.sas
......
sas E.sas
I am getting errors. Can some one help me ?
Are the files macros or programs? A macro doesn't really do anything until it is invoked. It sounds like you are taking about a series of programs instead of macros.
If they really are macros then perhaps you want to look into using an AUTOCALL library. Store each macro definition in its own file with the filename being the name of the macro plus an extenson of .sas (if you use Unix is important that the fllename be in all lowercase letters). Then point the SASAUTOS option to the directory where the macro code files are stored. SAS will then read the flle and compile the macro the first time it is requested in your actual program. So for example you could have a file named 'a.sas' that looked like:
%macro A;
%put Macro A will now call macro B;
%B;
%mend A;
And another file named 'b.sas' that looked like:
%macro B;
%put Macro B is running now;
%mend B;
You could then create a program that looked something like
%put Now running my program ;
options append=sasautos=('path to where macro source code lives');
%A;
Or since you seem to have an AUTOEXEC.SAS file you could put the SASAUTOS option setting into the autoexec file.
@KrisNori wrote:
....
I am getting errors. Can some one help me ?
Yeah. And a bicycle was stolen in Beijing.
Which, as information goes, is about as relevant to your problem.
Please post the relevant parts of your log files, if you get any. Or the operating system's response when you executed your command lines.
If macro A.sas contains valid %include statements for the other macros, you only need to execute A.sas.
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 16. 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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: