I have an autocall library called "general" that I want to convert into a macro catalog. The library contains many SAS files and I don't want to modify these to add a "/ store" option as instructed by SAS Help Center, storing macros. What I've tried instead is to read my macros into the current session, then save the WORK.SASMACR1 catalog to my current directory.
%include general("*.sas") / nosource2;
libname dnr "&_progdir";
proc catalog cat=work.sasmac1;
copy out=dnr.sasmac1;
run;
quit;
The filename "general" has been defined by a configuration macro, &_progdir points to the directory containing the program.
A macro catalog file "sasmac1.sas7bcat" is created and I can view the contents using PROC CATALOG but I can't use the macros. Here's the code I'm using:
libname dnr "<directory containing catalog>";
options mstored sasmstore=dnr;
/* Check the contents of the macro catalog */
proc catalog catalog = dnr.sasmac1;
contents;
quit;
/* Try one of the macros */
%put %quotelst2(a b c);
Can anyone point me in the right direction to get this code to work or perhaps point to an alternative method to create a macro catalog from an autocall library?
I'm running SAS 9.4M7 on LSAF 5.4 (this is why the macros are in WORK.SASMAC1, not SASMACR). LSAF runs SAS on Redhat Linux.
Since you are copying:
work.sasmac1;
it looks like you are working in SAS EG.
Try to do it like that:
%include general("*.sas") / nosource2;
libname dnr "&_progdir";
proc catalog cat=work.sasmac1;
copy out=dnr.sasmacr; /* <---------------- sasmacR instead sasmac1 */
run;
quit;
All the best
Bart
I don't know the answer to your question, but I have an autocall library and I would like to know out of curiosity, what are the benefits of a macro catalog compared to an autocall library?
Hi Paige,
I must say I'm not really of fan of catalogs, either for formats or for macros. In this case, I want a single file with macros from four autocall libraries that I can upload to a test version of LSAF. That would let me run my programs with minimal modifications to see how the new environment works.
In case you're not familiar, LSAF stands for Life Science Analytics Framework. It's a cloud based environment geared to the pharmaceutical industry, runs SAS 9.4M7 and R 4.1.Developing programs is more or less the same as PC SAS, running production versions requires extra steps
LSAF does not support autocall libraries? If so, that would seem to be simplest way to go.
I'm also not a fan of macro catalogs. That said, this paper has one approach for using a macro to read .sas files from an autocall library, copy them to a /temp location, edit the code to add /store, and then compile them all.:
https://www.pharmasug.org/proceedings/2021/AP/PharmaSUG-2021-AP-008.pdf
But for your use case, if LSAF doesn't make it easy to use an autocall library, I think my next thought would be to just use OS commands to concatenate all the .sas files in my autocall libraries into a single .sas file. Then I could push that file up to LSAF and %include it. It would of course be inefficient because would compile everything. And if you have macros with the same name in different libraries they would collide. But for quick-n-dirty development, I think I'd rather have a huge .sas file with all my macro definitions than have a permanent macro catalog.
To put your macros into a single file for easy transport to another system you can put them all into a package:
https://github.com/yabwon/SAS_PACKAGES
here is the "hell world" example: https://github.com/yabwon/SAS_PACKAGES/blob/main/SPF/Documentation/HelloWorldPackage.md
here is presentation from SGF2021: https://www.youtube.com/watch?v=hqexaQtGw88
Bart
Is the session where you create the macro catalog also SAS 9.4M7 on the same flavor of linux (same box?). It feels like your approach should work.
On the server where you created the permanent catalog, if you create a new session and try to use the catalog, does it work?
I suppose it's possible there is something 'special' about work.sasmac1 which makes a permanent copy not usable. But that would be surprising. More likely is that there is some difference in version/platform which is making it not work. Since catalogs are platform-specific.
I wonder if @yabwon has played with the idea of copying work.sasmacr as a hack for making a permanent macro catalog.?
I did 😉
Since you are copying:
work.sasmac1;
it looks like you are working in SAS EG.
Try to do it like that:
%include general("*.sas") / nosource2;
libname dnr "&_progdir";
proc catalog cat=work.sasmac1;
copy out=dnr.sasmacr; /* <---------------- sasmacR instead sasmac1 */
run;
quit;
All the best
Bart
Many thanks yabown, your solution works!
it's "yabwon", not "yabown" (I don't own a yab, whatewer "yab" is 🤣😂)
@yabwon wrote:
it's "yabwon", not "yabown" (I don't own a yab, whatewer "yab" is 🤣😂)
But what did Yab win?
A ski. 😉
My last name is "Jabłoński", if you want to pronounce it (in English) witch 94% correctness/accuracy you should say: yab - won - ski
😃
Bart
Sorry! 😧 I turn 65 in 3 weeks, you'd think I'd have learned to type by now!
😉
My favourite quote for all "that" situations is:
“An expert is a person who has made all the mistakes that can be made in a very narrow field.”
― Niels Bohr
😀
All the best
Bart
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 25. 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.