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

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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