BookmarkSubscribeRSS Feed
belboy
Obsidian | Level 7

Dear SAS community,

I have a macro that I've written called ROLES and sharing with my entire team.  The actual macro (over 1000 lines of code) is stored in a SAS folder and my team accesses the macro by executing the command below:

----------------------------------------------------------------------------------------

options mstored sasmstore= Roles;

libname Roles '/Attestation_QA2/BL';
%roles;

 

----------------------------------------------------------------------------------------

 

Sometimes when we are each running the macro (it's 5 of us) we get an error stating "A lock is not available for Roles.SASMACR.CATALOG."

 

I'm wondering if I change the libname option to access=readonly, would this solve the problem so that multiple users could execute at the same time?  

 

Something like this?:

------------------------------------------------------------------------------------------

options mstored sasmstore= Roles;

libname Roles '/Attestation_QA2/BL' access=readonly;
%roles;

-------------------------------------------------------------------------------------------

 

Does someone have a solution to fix this so that we don't get a "macro lock" error?  Will the access=readonly option work?  Your help is greatly appreciated.

 

Thx!

6 REPLIES 6
SASKiwi
PROC Star

I suggest you set up your macro in an AUTOCALL macro library. I have never had any locking problems with an AUTOCALL library:

 

http://documentation.sas.com/?docsetId=mcrolref&docsetTarget=p12b2qq72dkxpsn1e19y57emerr6.htm&docset...

 

Note in an AUTOCALL library your macro is stored as a text file containing the macro source code in the disk directory you have defined in your SASAUTOS system option. When you reference it in a program SAS automatically reads it and stores the macro in each users WORK.SASMACR catalog. This should prevent the locking problem you are experiencing. 

belboy
Obsidian | Level 7

Thanks SASKiwi,

I think this is what I need - I will test today once everyone returns to office and let you know.

 

 

ChrisNZ
Tourmaline | Level 20

No offense and not trying to be smart, but truly curious:It took you a lot longer to type this question than to try. Why not just try? Have you tried?

belboy
Obsidian | Level 7

Thanks Chris, 

Well I have to wait until today (Monday) to try it when everyone returns to the office.  In the meantime, I wanted to ask the SAS community if I was on the right track or not.  

 

 

Patrick
Opal | Level 21

@belboy

As I see things the sasmstore is for compiled macros to be used "system" or "project" wide. You should centrally manage this mstore and it should get defined during SAS invocation (in the .cfg or autoexec). Users shouldn't really have to connect to the mstore in their code.

 

Locking issues to a catalogue should only occur when someone is writing to the catalogue. With a centrally managed mstore and controlled times when new/changed macros get compiled into it, such locks shouldn't happen at all.

There is an option FILELOCKWAIT. I'm not sure if it also works for catalogs but it's certainly worth a try.

 

If I understand the setting you work in right:

It would eventually be better/easier to not use the mstore at all but instead to store macros as .sas files in a folder which is part of the SAS Autocall facility (part of the SASAUTOS search path). This would prevent all locking issues whatever you do. 

ChrisNZ
Tourmaline | Level 20

@belboy Fair enough. Apologies for the nosiness... 🙂

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
  • 6 replies
  • 1225 views
  • 1 like
  • 4 in conversation