BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Tom
Super User Tom
Super User

If you want to make your macros test their parameter values and report issues in a consistent way then look into creating a utility macro like:  %parmv() 

 

Then your test case becomes:

%macro myrealmacro
(country  /* Single country code */
,countrylist /* Space delimited list of country codes */
);
%local macro parmerr;
%let macro=&sysmacroname;
%parmv(country,_val=USA UK ENG)
%parmv(countrylist,_words=1,_val=USA UK ENG)
%if (&parmerr) %then %return;

%put Body of actual macro that uses &=COUNTRY and &=COUNTRYLIST goes here ;
%mend myrealmacro;

Example:

344   %myrealmacro(uk,usa uk);
Body of actual macro that uses COUNTRY=UK and COUNTRYLIST=USA UK goes here
345   %myrealmacro(usa uk ,france usa uk);

ERROR: Macro MYREALMACRO user error.
ERROR: USA UK is not a valid value for the COUNTRY parameter.
ERROR: The COUNTRY parameter may not have multiple values.
ERROR: Allowable values are: USA UK ENG.

ERROR: Macro MYREALMACRO user error.
ERROR: FRANCE USA UK is not a valid value for the COUNTRYLIST parameter.
ERROR: Allowable values are: USA UK ENG.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 15 replies
  • 1577 views
  • 2 likes
  • 3 in conversation