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;
I am sorry, I just simply missed to put ";" behind some of the statements....
I am sorry, I just simply missed to put ";" behind some of the statements....
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 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.