BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
FK1
Lapis Lazuli | Level 10 FK1
Lapis Lazuli | Level 10

Hi Folks,

 

I am trying to write a Macro, which writes (depending on the macro parameters) the source code of a compiled macro (from a macro catalog) into the log or a *sas file, respectively.

 

However, I always get an error message, when compiling the macro, which says:

 

"ERROR: Macro keyword END appears as text."

 

The problem ist obviously, that my %IF .... %THEN %DO .....  %END     %ELSE %DO..... %END;

case differentiation cannot be used with the %COPY Statement as it is already a macro by itself.

 

So my question is: how can I somehow get a workaround or mask the above mentioned macro key words?

 

 

Here is my code:

 

%MACRO get_macro_sourcecode(_makroname= , _librefMacKatalog= , _outPfad=) /store source DES="Makro, um den Sourcecode eines kompilierten Makros ins Log ODER in eine ' *.sas ' Datei auszugeben.";

/*Fall 1: Codeausgabe in *sas-Datei und libref UNGLEICH der libref in Systemoption "sasmstore" */
%IF  %sysevalf(%superq(_outPfad)= ,boolean) eq 0 AND  %sysevalf(%superq(_librefMacKatalog)= ,boolean) eq 0  %THEN %DO;
	%COPY %UPCASE(&_makroname.) /SOURCE  LIBRARY=&_librefMacKatalog.  out="&_outPfad.&_makroname..sas" 
%END;

/*Fall 2: Codeausgabe in *sas-Datei und libref GLEICH der libref in Systemoption "sasmstore" */
%IF  %sysevalf(%superq(_outPfad)= ,boolean) eq 0 AND  %sysevalf(%superq(_librefMacKatalog)= ,boolean) eq 1 %THEN %DO;
	%COPY %UPCASE(&_makroname.) /SOURCE  out="&_outPfad.&_makroname..sas" 
%END;

/*Fall 3: Keine Ausgabe in ".sas" - Datei, sondern Ausgabe ins Log und libref UNGLEICH der libref in Systemoption "sasmstore" */
%IF %sysevalf(%superq(_outPfad)= ,boolean) eq 1 AND %sysevalf(%superq(_librefMacKatalog)= ,boolean) eq 0  %THEN %DO;
	%COPY %UPCASE(&_makroname.) /SOURCE LIBRARY=&_librefMacKatalog. ;
%END;

/*Fall 4: Keine Ausgabe in ".sas" - Datei, sondern Ausgabe ins Log und libref GLEICH der libref in Systemoption "sasmstore" */
%IF %sysevalf(%superq(_outPfad)= ,boolean) eq 1 AND %sysevalf(%superq(_librefMacKatalog)= ,boolean) eq 1  %THEN %DO;
	%COPY %UPCASE(&_makroname.) /SOURCE LIBRARY=&_librefMacKatalog. ;
%END;

%MEND;

 

1 ACCEPTED SOLUTION

Accepted Solutions
FK1
Lapis Lazuli | Level 10 FK1
Lapis Lazuli | Level 10

I am sorry, I just simply missed to put ";" behind some of the statements....

View solution in original post

2 REPLIES 2
FK1
Lapis Lazuli | Level 10 FK1
Lapis Lazuli | Level 10

I am sorry, I just simply missed to put ";" behind some of the statements....

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Post the log, with options mlogic mprint symbolgen turned on.  Also, please avoid coding in SHOUTING case, it really makes code hard to read.

sas-innovate-wordmark-2025-midnight.png

Register Today!

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.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1943 views
  • 0 likes
  • 2 in conversation