BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
ckx
Quartz | Level 8 ckx
Quartz | Level 8

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.

 

1 ACCEPTED SOLUTION

Accepted Solutions
yabwon
Onyx | Level 15

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

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



View solution in original post

14 REPLIES 14
PaigeMiller
Diamond | Level 26

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?

--
Paige Miller
ckx
Quartz | Level 8 ckx
Quartz | Level 8

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

PaigeMiller
Diamond | Level 26

LSAF does not support autocall libraries? If so, that would seem to be simplest way to go.

--
Paige Miller
Quentin
Super User

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.

BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
yabwon
Onyx | Level 15

 

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

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



Quentin
Super User

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.?

BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
yabwon
Onyx | Level 15

I did 😉

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



yabwon
Onyx | Level 15

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

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



ckx
Quartz | Level 8 ckx
Quartz | Level 8

Many thanks yabown, your solution works!

 

yabwon
Onyx | Level 15

it's "yabwon", not "yabown" (I don't own a yab, whatewer "yab" is 🤣😂)

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



Tom
Super User Tom
Super User

@yabwon wrote:

it's "yabwon", not "yabown" (I don't own a yab, whatewer "yab" is 🤣😂)


But what did Yab win?

yabwon
Onyx | Level 15

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

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



ckx
Quartz | Level 8 ckx
Quartz | Level 8

Sorry! 😧 I turn 65 in 3 weeks, you'd think I'd have learned to type by now!

yabwon
Onyx | Level 15

😉

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

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 14 replies
  • 1322 views
  • 5 likes
  • 5 in conversation