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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 1537 views
  • 0 likes
  • 2 in conversation