How to store SAS Macros in a permanent Library?
proc import datafile="D:\SAS Docs\CDM Docs\Protocol.xlsx" dbms=xlsx out=&set replace;
proc print data=&set;run;
This is a macro but it is getting stored in Work Library. I want to store it in a permanent Library. How?
Read the documentation that I linked in my previous post. If you have specific questions, ask them.
It is possible to store COMPILED macros into catalogs and tell SAS to look for them there.
But it is much easier to create and manage if you use the SASAUTOS facility instead. Use the SASAUTOS option to point to a folder (or series of folders) where SAS can look for an auto-compile the macro from the source. Place each macro in its own individual file. Name the file with the name of the macro with .sas extension. Make sure to use lowercase letters for the filename. So your example should be stored in a file named import.sas.
Please explain the Syntax of Sasautos in SAS environment.
Make a directory on you filesystem. For example
Make a macro and store it in a file in that directory. For example a macro name %MyMac() might be in a file named.
And have content like:
%macro MyMac(dsname); proc contents data=&dsname; run; %mend MyMac;
Then in your main program add this line to tell SAS where to find the macros:
And then after than in your main program you just call the macro.
If you have called it before it just runs, but if not then SAS will search the folders in the SASAUTOS option tor the file named 'mymac.sas' and include it. Then, now that the macro has been compiled, it calls it.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.