DATA Step, Macro, Functions and more

Renewing the Macro Library

Accepted Solution Solved
Reply
Contributor
Posts: 65
Accepted Solution

Renewing the Macro Library

Hi all,

 

I've been using a macro library so that I can use macros without compiling them first. The problem is that when I change the macro and save it, then refresh my filename for the macro lib, this is not enough to update and use the new macro?

 

Anyone have any ideas why it is still using and compiling the old macro before it was saved?


Accepted Solutions
Solution
‎03-26-2018 11:18 AM
Respected Advisor
Posts: 3,001

Re: Renewing the Macro Library

[ Edited ]

@89974114 wrote:

Hi all,

 

I've been using a macro library so that I can use macros without compiling them first. The problem is that when I change the macro and save it, then refresh my filename for the macro lib, this is not enough to update and use the new macro?

 

Anyone have any ideas why it is still using and compiling the old macro before it was saved?


When you change a macro and save it, SAS doesn't use the saved copy if you have previously used the macro in that session. It uses the version of the macro before the changes that is still in SAS's memory.

 

To make sure the changed macro is used, you need to submit the macro via the SAS Editor.

 

http://documentation.sas.com/?cdcId=pgmmvacdc&cdcVersion=9.4&docsetId=mcrolref&docsetTarget=n1o5fkxq...

 

Capture.PNG

--
Paige Miller

View solution in original post


All Replies
Super User
Posts: 13,523

Re: Renewing the Macro Library

If you are using a compiled macro library then you must re-compile the macro to use the new version. Saving the source code is not enough.

 

System options such as mautosource, mstored, mcompile, mrecall and mreplace also may come into play as well.

 

 

 

Solution
‎03-26-2018 11:18 AM
Respected Advisor
Posts: 3,001

Re: Renewing the Macro Library

[ Edited ]

@89974114 wrote:

Hi all,

 

I've been using a macro library so that I can use macros without compiling them first. The problem is that when I change the macro and save it, then refresh my filename for the macro lib, this is not enough to update and use the new macro?

 

Anyone have any ideas why it is still using and compiling the old macro before it was saved?


When you change a macro and save it, SAS doesn't use the saved copy if you have previously used the macro in that session. It uses the version of the macro before the changes that is still in SAS's memory.

 

To make sure the changed macro is used, you need to submit the macro via the SAS Editor.

 

http://documentation.sas.com/?cdcId=pgmmvacdc&cdcVersion=9.4&docsetId=mcrolref&docsetTarget=n1o5fkxq...

 

Capture.PNG

--
Paige Miller
Contributor
Posts: 65

Re: Renewing the Macro Library

Posted in reply to PaigeMiller

Great answer, thanks. I'll start looking for a function that clears the macro library where the recently compiled functions are

Respected Advisor
Posts: 3,001

Re: Renewing the Macro Library


@89974114 wrote:

Great answer, thanks. I'll start looking for a function that clears the macro library where the recently compiled functions are


When you modify a macro, just submit the code. Nothing more complicated than that is needed.

--
Paige Miller
Contributor
Posts: 65

Re: Renewing the Macro Library

Posted in reply to PaigeMiller

It's not an ideal solution as it's a package of many macros which is going to be handed over to someone else to use

Respected Advisor
Posts: 3,001

Re: Renewing the Macro Library


@89974114 wrote:

It's not an ideal solution as it's a package of many macros which is going to be handed over to someone else to use


I don't see how this relates to the rest of the thread.

--
Paige Miller
Contributor
Posts: 65

Re: Renewing the Macro Library

Posted in reply to PaigeMiller

If I understand, I read your comment such that I need to run the code again before proceeding with a run of the package, or are you saying just run the macro again with the file kept elsewhere?

Respected Advisor
Posts: 3,001

Re: Renewing the Macro Library


@89974114 wrote:

If I understand, I read your comment such that I need to run the code again before proceeding with a run of the package, or are you saying just run the macro again with the file kept elsewhere?

 


It's not an ideal solution as it's a package of many macros which is going to be handed over to someone else to use

Nowhere in the previous discussion has a "package" been mentioned. Please explain.

--
Paige Miller
Contributor
Posts: 65

Re: Renewing the Macro Library

Posted in reply to PaigeMiller

The package would just be a usb with the macro file on it and a cover programme to run with macros manifested inside

Respected Advisor
Posts: 3,001

Re: Renewing the Macro Library

[ Edited ]

So I still don't understand what this has to do with the original question. In the original question, you (not someone else) saved a macro and then SAS continued to use the old macro. Please explain the linkage between the original question where you change a macro; and giving the software to someone else.

--
Paige Miller
Super User
Posts: 13,523

Re: Renewing the Macro Library


@89974114 wrote:

The package would just be a usb with the macro file on it and a cover programme to run with macros manifested inside


One would suggest that if you are still testing and modifying the macros then the macros are not ready to share.

 

Also having compiled macros without the source code is one of the ways that organizations can hurt themselves. The binary compiled macros may not transfer across operating systems or OS with different "bitness". Macros compiled in a 32-bit system will not work for one running 64-bit version of the same operating system, or vice versa. If you search this forum you can find instances of organizations that had "lost" the source code of the macros, updated their systems and had the macro library stop working and throw errors due to this. And then trying to regenerate the source fails.

 

If you insist on the compiled macros the consider using the option SOURCE option as well as STORE. That way if you have one of the above issues later it is possible to recover the macro definition by finding an older version of SAS and/or OS but having the code in a source catalog along with the macro. Keep the source and macros in the same library.

Contributor
Posts: 65

Re: Renewing the Macro Library

I was just under the impression that paige said I'd have to compile the macros by hand everytime I make a change which wouldn't be ideal once I leave this package of macros to the next person, who may or may not want to change them in the future.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 12 replies
  • 127 views
  • 0 likes
  • 3 in conversation