BookmarkSubscribeRSS Feed
FK21
Fluorite | Level 6

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

3 REPLIES 3
Tom
Super User Tom
Super User

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
s_lassen
Meteorite | Level 14

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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 351 views
  • 2 likes
  • 4 in conversation