Hi SAS folks,
I am trying to create a catalog (sas7bcat file) named "vdt_test" which shell have a compiled macro in it called "get_info".
When running the following code:
%LET PGname_in = getinfomacro;
%LET PGNname_in_cat = get_info ;
%LET catname = vdt_test;
%LET entrytype = MACRO;
libname _catloc base "/sas/sources/catalogs/";
filename inputPG "/tmp/&PGname_in..sas" ;
data _null_;
file inputPG;
infile datalines delimiter="," truncover;
length line $1000.;
input line $;
put _infile_;
datalines4;
%MACRO get_info(p_Env= ,p_Uname= ,p_Macvarname=) / SECURE STORE ;
/* set scope for user-given macro variablen */
%IF %SYMEXIST(&p_Macvarname.) = 0 %THEN %DO;
%GLOBAL &p_Macvarname;
%END;
%ELSE %DO;
%PUT ERROR: Makrovariablenname "&p_Macvarname" bereits vergeben.;
%END;
%IF %UPCASE(&p_Env.) eq E %THEN %DO;
%IF %UPCASE(&p_Uname.) eq SASBATCH %THEN %LET &p_Macvarname. = Tokenstring1;
%IF %UPCASE(&p_Uname.) eq SASTOKEN %THEN %LET &p_Macvarname. = Tokenstring2;
%END;
%IF %UPCASE(&p_Env.) eq T %THEN %DO;
%IF %UPCASE(&p_Uname.) eq SASBATCH %THEN %LET &p_Macvarname. = Tokenstring3;
%IF %UPCASE(&p_Uname.) eq SASTOKEN %THEN %LET &p_Macvarname. = Tokenstring4;
%END;
%IF %UPCASE(&p_Env.) eq P %THEN %DO;
%IF %UPCASE(&p_Uname.) eq SASBATCH %THEN %LET &p_Macvarname. = Tokenstring5;
%IF %UPCASE(&p_Uname.) eq SASTOKEN %THEN %LET &p_Macvarname. = Tokenstring6;
%END;
%IF %UPCASE(&p_Env.) eq AD %THEN %DO;
%IF %UPCASE(&p_Uname.) eq %STR($SASBATCH) %THEN %LET &p_Macvarname. = Tokenstring7;
%END;
%MEND;
;;;;
run;
data _null_ ;
filename mycat catalog "_catloc.&catname." lrecl= 256 ;
file mycat("&PGNname_in_cat..&entrytype.") ;
infile inputPG;
input ;
put _infile_ ;
run ;
proc catalog CATALOG= _catloc.&catname. ;
contents ;
run;
quit ;
I get this ERROR message:
ERROR: Output mode is only supported for catalog entry types of SOURCE, LOG, OUTPUT, HTML, JPEG, GIF, CSS, WML, XML, XSL, RTF, PDF, PS, CSV, JS, VBS, JAR, CATAMS, HPFPROJ, HPFDATA, HPFEVENT, HPFDIAG, HPFSPEC, HPFLIST, HPFSCORE, PNG, and HPF1-HPF10.
Here is my question:
why the heck is it not possible to name a catalog which contains a compiled macro other than "SASMACR", which is the name given automatically by the system when just running the "%MACRO" step with the options "store" and "secure"?
Any help would be highly appreaciated,
FK21
I have never found any utility in storing compiled macros. I find it much easier to store the macro code as a plain text file and use the SASAUTOS functionality to have in compiled the first time I ask for it.
I have no idea if you can ask SAS to compile into a different catalog than the default. (Note that if you are using front ends like Enterprise Guide or SAS/Studio to run your code the default catalog name is SASMAC1 instead of SASMACR. I also have no idea why SAS does that either.)
But it should be trivial to compile the macros you want and use PROC CATALOG to copy them into the target catalog.
1 %macro example; 2 %put This is an example macro ; 3 %mend; 4 5 proc catalog cat=work.sasmacr ; 6 copy out=work.stored_compiled_macros; 7 select example / et=macro; 8 run; NOTE: Copying entry EXAMPLE.MACRO from catalog WORK.SASMACR to catalog WORK.STORED_COMPILED_MACROS. 9 quit; NOTE: PROCEDURE CATALOG used (Total process time): real time 0.01 seconds cpu time 0.00 seconds
You can use the SASMSTORE option to place the compiled macro in the SASMACR catalog in a different library, e.g.:
options mstored sasmstore=MYLIB;
- the compiled macro should then be in the catalog MYLIB.SASMACR.
A SASMACR entry is a compiled macro, which is created when the macro code (from %MACRO to %MEND) is executed. It is not the raw macro code!
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.