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