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?
@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.
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.
@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.
Great answer, thanks. I'll start looking for a function that clears the macro library where the recently compiled functions are
@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.
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
@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.
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?
@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.
The package would just be a usb with the macro file on it and a cover programme to run with macros manifested inside
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.
@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.
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.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.