DATA Step, Macro, Functions and more

%COPY Statement, Error: "Macro keyword END appears as text.

Accepted Solution Solved
Reply
Contributor FK1
Contributor
Posts: 40
Accepted Solution

%COPY Statement, Error: "Macro keyword END appears as text.

[ Edited ]

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;

 


Accepted Solutions
Solution
Thursday
Contributor FK1
Contributor
Posts: 40

Re: %COPY Statement, Error: "Macro keyword END appears as text.

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

View solution in original post


All Replies
Solution
Thursday
Contributor FK1
Contributor
Posts: 40

Re: %COPY Statement, Error: "Macro keyword END appears as text.

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

Super User
Super User
Posts: 9,415

Re: %COPY Statement, Error: "Macro keyword END appears as text.

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

☑ This topic is solved.

Need further help from the community? Please ask a new question.

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