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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1161 views
  • 2 likes
  • 3 in conversation