BookmarkSubscribeRSS Feed
imdickson
Quartz | Level 8

Hello Everyone.

 

I need help to solve this macro. My macro is as below:

 

%macro checkabc();
	%if %sysfunc(scan(&SCREAM,-1,'_') eq 'ABC' %then %do;
		%let SCREEN = %sysfunc(tranwrd(&SCREAM,'_ABC',)
	%END;
%end;
%checkabc;

i am getting the following error:

ERROR: Macro keyword DO appears as text.
ERROR: A dummy macro will be compiled.
90        +		%let SCREAM = %sysfunc(tranwrd(&SCREAM,'_ABC',)
ERROR: Macro keyword LET appears as text.
91        +	%END;
92        +%end;
ERROR: Macro keyword END appears as text.

 

I suspect 1 or more code is not quoted properly/wrongly used. I need advice on how to improve this macro.

 

Hope to get advice soon. 🙂

Thanks a lot everyone.

 

5 REPLIES 5
LinusH
Tourmaline | Level 20
You are missing a right parenthesis.
Data never sleeps
imdickson
Quartz | Level 8

Thanks for the help. I missed out 2 right parenthesis.

I also added 2 single quote in tranwrd.

 

However, I am still getting error as below.

ERROR: Macro keyword END appears as text.
ERROR: A dummy macro will be compiled.

 

My current macro code:

%macro checkabc();
	%if %sysfunc(scan(&SCREAM,-1,'_')) eq 'ABC' %then %do;
		%let SCREAM = %sysfunc(tranwrd(&SCREAM,'_ABC',''))
	%END;
%end;
%checkabc;	

 

what else could be wrong here.....

LinusH
Tourmaline | Level 20
You are now missing a semi colon, and you have to use %mend, not %end.
Data never sleeps
s_manoj
Quartz | Level 8
s you already aware about parenthesis were missing,
; is missing for %let statement and after %end have to inlude %mend;

Ksharp
Super User
%macro checkabc;
	%if %sysfunc(scan(&SCREAM,-1,_)) eq ABC %then %do;
		%let SCREAM = %sysfunc(tranwrd(&SCREAM,_ABC,%str( )));
	%END;
%mend;


%let scream=XX_ABC ;
%put before: &scream;
%checkabc
%put after: &scream;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 5 replies
  • 9097 views
  • 1 like
  • 4 in conversation