DATA Step, Macro, Functions and more

save macro as executable programm

Reply
Contributor
Posts: 32

save macro as executable programm

Hi, i have two questions, would you help me please :

1/ I create my first macro in sas Smiley Wink and i m asking how to save it as executable.

2/ how to combine between sas enterprise quide and sas/af ?

(i'm working on sas enterprise quide 4.3)

Super User
Posts: 3,260

Re: save macro as executable programm

I find the easiest way to manage SAS macros is to put them in an AUTOCALL library: SAS(R) 9.3 Macro Language: Reference

When you call the AUTOCALL macro in your SAS program, SAS will automatically search for it, run the macro to define then run your call of it - it does not need to be run in advance.

AUTOCALL macros will work fine in EG or in a SAS/AF submit block. 

Contributor
Posts: 32

Re: save macro as executable programm

Thank you SASKiwi. Do you know how I can find the autocall library in the enterprise server (in wich sas is installed) because i m not working on my laptop?

SAS Employee
Posts: 340

Re: save macro as executable programm

proc options option=sasautos;run;

libname sasautos list;

But you can extend this search path with:

libname mylib 'C:\temp';

options sasautos=(mylib, sasautos);

Now you can save a macro called %myfirstmacro with a file name: C:\temp\myfirstmacro.sas

Contributor
Posts: 32

Re: save macro as executable programm

Posted in reply to gergely_batho

Hi Gergely,

that's what i used:

filename mylib "/folders/myfolders/myautocall";

options mautosource sasautos=(mylib sasautos)  mautolocdisplay;

%PARCRECH(8000, Dec, '/folders/myfolders/files/file.txt')

and it displays this:


1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;

42 ;

43 filename mylib "/folders/myfolders/myautocall";

44 

45 options mautosource sasautos=(mylib sasautos) mautolocdisplay;

WARNING: Apparent invocation of macro PARCRECH not resolved.

46 

47 %PARCRECH(8000, Dec, '/folders/myfolders/files/rechareg_echantillon_janvier.txt')

  _

  180

ERROR 180-322: Statement is not valid or it is used out of proper order.

SAS Employee
Posts: 340

Re: save macro as executable programm

Your code looks fine.

1. Your file (where the macro is saved) is called parcrech.sas (lowcase!)?

2. The file should contain only the macro definition.

3. Make sure the macro has 3 parameters (as in the call of the macro).

4. When you make a failed attempt to auto-load the macro, restart your SAS session. Otherwise it will not try to find it again. Or use: options mrecall;

Super User
Posts: 11,343

Re: save macro as executable programm

Posted in reply to gergely_batho

It may not hurt to expand on Gergely rule 2: First thing in the source file: %macro PARCRECH (<parameters>);

You may also need to invoke it as:

%PARCRECH(8000, Dec,%str( '/folders/myfolders/files/rechareg_echantillon_janvier.txt'));

Contributor
Posts: 32

Re: save macro as executable programm

Posted in reply to gergely_batho

thanks Gergely, the was called "ParcRech.sas".

Contributor
Posts: 32

Re: save macro as executable programm

thank you

Super User
Posts: 3,260

Re: save macro as executable programm

It looks like your SAS runs on Unix. In that case ALL autocall macro program names must be in lower case otherwise they wont be recognised:

33772 - Names of autocall macro .sas files must be lowercase in the UNIX environment

Ask a Question
Discussion stats
  • 9 replies
  • 412 views
  • 2 likes
  • 4 in conversation