BookmarkSubscribeRSS Feed
fadel
Calcite | Level 5

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)

9 REPLIES 9
SASKiwi
PROC Star

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. 

fadel
Calcite | Level 5

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?

gergely_batho
SAS Employee

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

fadel
Calcite | Level 5

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.

gergely_batho
SAS Employee

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;

ballardw
Super User

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'));

fadel
Calcite | Level 5

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

fadel
Calcite | Level 5

thank you

SASKiwi
PROC Star

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 9 replies
  • 1130 views
  • 2 likes
  • 4 in conversation