Getting a macro to resolve from autocall library

Reply
New Contributor
Posts: 3

Getting a macro to resolve from autocall library


I'm using EG 9.3 version 5.1. I have a macro that I created that works perfectly using %include. I am would like to add the macro to the autocall library and I've tried the following approaches but neither work. I'm including the code and the log for both attempts in the attachment. The code for the macro that I'm calling is included at the end. It is saved as 'pgm_cd.sas' on a unix server.

Any help would be appreciated. Thank you!

New Contributor
Posts: 2

Re: Getting a macro to resolve from autocall library

Try using ---  options MAUTOLOCDISPLAY    .   Interesting that your request shows up as I am preparing a paper for 2014 SAS Global Forum.  Here is a quote out of it: 

"Macros are relatively easy to run from their native locations.  This paper covers methods of doing this with emphasis on:  (a) the option “sasautos” to define the location and the search order for identifying macros being called, and (b) even more importantly -- the little known SAS option “MAUTOLOCDISPLAY” to identify the location of the macro actually called in the saslog.  What you think you are calling and what actually was called may be two different things."

This may or may not help you resolve your issues.

New Contributor
Posts: 3

Re: Getting a macro to resolve from autocall library

Thanks for your reply. I didn't see any results in the log that were different than the prior runs but I think you may be on to something. I am running these macros from my local windows machine on a remote unix server using EG. It looks like it's an issue with the path when I call the macro. Could the windows/unix translation be the foul up?

New Contributor
Posts: 2

Re: Getting a macro to resolve from autocall library

My first question here is do you have mautosource option on.  I see that you do.

Here is an article that might help you some.  

http://support.sas.com/kb/00/444.html

Super User
Super User
Posts: 7,079

Re: Getting a macro to resolve from autocall library

In addition to the path you need to take care with the filenames.  For autocall to work the filename must match the macro name and on Unix this means that the filename must be in all lowercase.  So if you want to use %mymacro() in your SAS code then the macro must be in a file name 'mymacro.sas'.  When you %include you can by pass both of these issues as the filename does not need to match the macro name and the filename can include uppercase letters.

Valued Guide
Posts: 2,177

Re: Getting a macro to resolve from autocall library

. I am running these macros from my local windows machine on a remote unix server using EG. It looks like it's an issue with the path when I call the macro.

Where (server) SAS compiles the macro is important!

Has that user account (on the SAS server) the rights to see and read from your macro folder on your EG client?

PROC Star
Posts: 1,325

Re: Getting a macro to resolve from autocall library

Good tips from all.

Tom's point about filenames on unix for macro autocall libraries killed about 1 day of productivity for me years back.  We were moving a bunch of code to Windows, and I couldn't figure out why 1/3 of my autocall macros didn't work.

To that point:

1. Do the SAS-provided autocall macros work?  i.e. %put %lowcase(AbCd) ;    [I think that's an autocall macro, if not, %upcase() is, I can never remember... ]

2. If you copy your macro file to the same directory where the SAS supplied macro files are, does your macro work?  If not, then it's probably the filename case problem.  If it does, then it's probably a problem with your assignment of the autocall path or file ref.

--Q

Valued Guide
Posts: 2,177

Re: Getting a macro to resolve from autocall library

Option insert=sasautos 'path to your folder of macros' ;

became available in SAS9.2  (iirc)

New Contributor
Posts: 3

Re: Getting a macro to resolve from autocall library

Thanks Peter. That worked. The final syntax looked like this.

mac1 '/_analytics/bi_product_uw/m_pgms';


sasautos=('/_analytics/bi_product_uw/m_pgms' sasautos)

mautosource mstored mautolocdisplay;

%pgm_cd

The program was called pgm_cd.sas and it was located in this directory.

/_analytics/bi_product_uw/m_pgms

Thanks for the assist.


Trusted Advisor
Posts: 3,215

Re: Getting a macro to resolve from autocall library

Unix (Linux)

changes should be made at the config/Levx/<Appserver> usermod files  you will find a/ autoexec b/ config  c/ env.sh files for that.

This is a platform admin job. This guy should understand OS layers and SAS and ..... and the business.  For HR-management simplicity that is not always done so you could have an issue with that.

The best thing is adjust a usermod-config file to a agreed location for the user-macro-s.

Some attention points:

- The default assumption is that the user-application is placed just in some mapping very close to those config/installation-files. 

  That coul be a failing approach by other manadatory guidelines.   

  You could use OS enviroment vars into namings (! instead of &)

- The relative path to those mapping is failing with the home location direction (change currrent dir and relatieve path fails  - KB-notes).

  50345 - Changing the current working directory for the SAS® Workspace Server

- Never mix-up capitals in the SAS macro-names at OS level (hungarian style) .  They will fail as only low-case chars in the namings will work.  

---->-- ja karman --<-----
Ask a Question
Discussion stats
  • 9 replies
  • 1088 views
  • 3 likes
  • 6 in conversation