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

How to compile Macro into a physical directory? Whenever SAS is open, the macro is there to run?!

 

Also to encrypt it; to make it "unreadable" even with OPION MPRINT...

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

When compiling a macro you can add the option SECURE on the %MACRO statement. Documentation indicates you should not store passwords or code segments, use for entire Proc or Data step. The STORE option lets you specify a specific library and catalog location for the compiled result. Use the system option SASMSTORE= to specify a permanent location. You will need to have the system option MSTORED to use the macro. Read the options of the %MACRO statement in the documentation.

 

Caveat: code compiled in a macro code is specific to OS and version. Catalogs created in SAS 9.3 are not usable by 9.4 and may have issues with the incremental releases.

 

Do not lose track of the source code or you will not be able to recover the code. We have had that question asked a few times on the forum.

View solution in original post

3 REPLIES 3
ballardw
Super User

When compiling a macro you can add the option SECURE on the %MACRO statement. Documentation indicates you should not store passwords or code segments, use for entire Proc or Data step. The STORE option lets you specify a specific library and catalog location for the compiled result. Use the system option SASMSTORE= to specify a permanent location. You will need to have the system option MSTORED to use the macro. Read the options of the %MACRO statement in the documentation.

 

Caveat: code compiled in a macro code is specific to OS and version. Catalogs created in SAS 9.3 are not usable by 9.4 and may have issues with the incremental releases.

 

Do not lose track of the source code or you will not be able to recover the code. We have had that question asked a few times on the forum.

hellohere
Pyrite | Level 9

Thanks.

 

I run the SAS DOC codes below. It is fine.

 

But one quest: options mstored sasmstore=mylib; tells SAS to find Macro in mylib; DOES that mean work.sasmacr is not working then?!

 

options mstored sasmstore=mylib;
libname mylib "C:\Users\24891\sas";
%macro secure/store secure; /* This macro is encrypted */
data _null_;
x=1;
put "This data step was generated from a secure macro.";
run;
%mend secure;
%secure;

filename maccat catalog 'mylib.sasmacr.secure.macro';
data _null_;
infile maccat;
input;
list;
run;

SASKiwi
PROC Star

I suggest you read the documentation on this subject. Once the SASMSTORE option is set. All macros compiled afterwards will be stored in that location. If you already have macros in WORK.SASMACR then those should continue to work.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 3 replies
  • 454 views
  • 0 likes
  • 3 in conversation