<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Macro Validation - A list of values in another list of values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754329#M237851</link>
    <description>&lt;P&gt;Going back to your original code which has this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %upcase(&amp;amp;country.) in (USA UK ENG) and %upcase(&amp;amp;countrylist.) in (USA UK ENG) %then %do;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You need to check &amp;amp;countrylist is valid in one %IF block, and check if the &amp;amp;Country is contained in &amp;amp;countrylist in a different %IF block.&lt;/P&gt;
&lt;P&gt;To check if &amp;amp;countrylist is valid, you would need to specifically loop through each element of &amp;amp;countrylist.&lt;/P&gt;</description>
    <pubDate>Thu, 15 Jul 2021 14:09:04 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-07-15T14:09:04Z</dc:date>
    <item>
      <title>Macro Validation - A list of values in another list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754318#M237843</link>
      <description>&lt;P&gt;I am creating a macro, and would like to validate a parameter, i.e. to check if a list of values is contained in another list of values. If this is NOT the case, I will put an error message to the user.&lt;BR /&gt;&lt;BR /&gt;The code I was trying:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro ValidateCountries(country, countrylist) /minoperator mindelimiter=' ';
	%if %upcase(&amp;amp;country.) in (USA UK ENG) and %upcase(&amp;amp;countrylist.) in (USA UK ENG) %then %do;
		%local answer;
		%if &amp;amp;country. in &amp;amp;countrylist. %then %do; 
		  %let answer= 1; 
		%end; 
		%else %do;
		  %let answer= 0; 
		%end;
		&amp;amp;answer; 
	%end;

	%else %do; 
		%put Error: country should be one of: USA UK ENG. 
					countrylist may only contain some of USA UK ENG. ;
	%end; 	
%mend; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I believe the problem is in this code:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;and %upcase(&amp;amp;countrylist.) in (USA UK ENG) %then %do;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks for the help.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 13:14:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754318#M237843</guid>
      <dc:creator>SasStatistics</dc:creator>
      <dc:date>2021-07-15T13:14:09Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Validation - A list of values in another list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754322#M237844</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/381436"&gt;@SasStatistics&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I believe the problem is in this code:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;and %upcase(&amp;amp;countrylist.) in (USA UK ENG) %then %do;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks for the help.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It's not&amp;nbsp; clear what the purpose of this part of the code is. But it is not a syntax error.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 13:26:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754322#M237844</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-15T13:26:54Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Validation - A list of values in another list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754323#M237845</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro ValidateCountries(country, countrylist) /minoperator mindelimiter=' ';
	%if %upcase(&amp;amp;country.) in (&amp;amp;countrylist) %then 1;
    %else 0;
%mend; 

%put ANSWER %validateCountries(uk,USA UK ENG);
%put ANSWER2 %validateCountries(turkey,USA UK ENG);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Would this work for you?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 13:31:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754323#M237845</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-15T13:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Validation - A list of values in another list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754324#M237846</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;. I hope this example makes it more clear:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let MyRes1 = %ValidateCountries(USA, USA UK); * Program goes to the %else %do statement, but USA and UK is in the list of USA, UK and ENG so I would like it to return the answer 1. ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Jul 2021 13:34:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754324#M237846</guid>
      <dc:creator>SasStatistics</dc:creator>
      <dc:date>2021-07-15T13:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Validation - A list of values in another list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754325#M237847</link>
      <description>Unfortunately not, I must beforehand validate that countrylist is a list only containing the combinations of (USA, UK, ENG). For example (USA and UK) would be valid as would USA alone. &lt;BR /&gt;&lt;BR /&gt;But USA, UK,  GER would not be valid and should return an error.</description>
      <pubDate>Thu, 15 Jul 2021 13:35:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754325#M237847</guid>
      <dc:creator>SasStatistics</dc:creator>
      <dc:date>2021-07-15T13:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Validation - A list of values in another list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754326#M237848</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/381436"&gt;@SasStatistics&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Unfortunately not, I must beforehand validate that countrylist is a list only containing the combinations of (USA, UK, ENG). For example (USA and UK) would be valid as would USA alone. &lt;BR /&gt;&lt;BR /&gt;But USA, UK, GER would not be valid and should return an error.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Why then don't you just hardcode the country list instead of making a variable that could have values you don't want?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro ValidateCountries(country) /minoperator mindelimiter=' ';
	%if %upcase(&amp;amp;country.) in (USA UK ENG) %then 1;
    %else 0;
%mend; 

%put ANSWER %validateCountries(uk);
%put ANSWER2 %validateCountries(turkey);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Jul 2021 13:40:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754326#M237848</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-15T13:40:06Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Validation - A list of values in another list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754328#M237850</link>
      <description>Since different scripts require different cases. &lt;BR /&gt;&lt;BR /&gt;In one script i want to check that the country list is USA or UK and make sure the user does no misstake such as USA, UK and GER. &lt;BR /&gt;In another script I want to check that the country list is UK, ENG and make sure the user does no misstake such as UK, ENG and AUS. &lt;BR /&gt;&lt;BR /&gt;Any ideas? &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 15 Jul 2021 13:45:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754328#M237850</guid>
      <dc:creator>SasStatistics</dc:creator>
      <dc:date>2021-07-15T13:45:54Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Validation - A list of values in another list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754329#M237851</link>
      <description>&lt;P&gt;Going back to your original code which has this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %upcase(&amp;amp;country.) in (USA UK ENG) and %upcase(&amp;amp;countrylist.) in (USA UK ENG) %then %do;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You need to check &amp;amp;countrylist is valid in one %IF block, and check if the &amp;amp;Country is contained in &amp;amp;countrylist in a different %IF block.&lt;/P&gt;
&lt;P&gt;To check if &amp;amp;countrylist is valid, you would need to specifically loop through each element of &amp;amp;countrylist.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 14:09:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754329#M237851</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-15T14:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Validation - A list of values in another list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754332#M237854</link>
      <description>&lt;P&gt;Are you just trying to check if ONE value is in a list of possible values?&amp;nbsp; Or are you trying to check if all of a list of values in in another list?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Set the result to GOOD and then loop over the list of words to check and set it BAD for any failure.&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro ValidateCountries(country, countrylist) /minoperator mindelimiter=' ';
  %local answer i next;
  %let answer=1;
  %do i=1 %to %sysfunc(countw(&amp;amp;country));
    %let next=%qscan(&amp;amp;country,&amp;amp;i,%str( ));
    %if not (%qupcase(&amp;amp;next) in %qupcase(&amp;amp;countrylist)) %then %do;
       %let answer=0;
       %put ERROR: Value &amp;amp;next is not in list: &amp;amp;countrylist;
    %end;
  %end;
  %if not &amp;amp;answer %then %put ERROR: Invalid list of countries: &amp;amp;=country;
&amp;amp;answer
%mend; 

%put %ValidateCountries(uk,usa uk);
%put %validateCountries(usa uk france,usa uk);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 14:00:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754332#M237854</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-15T14:00:17Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Validation - A list of values in another list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754335#M237857</link>
      <description>&lt;P&gt;The purpose of the validation code:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %upcase(&amp;amp;country.) in (USA UK ENG) and %upcase(&amp;amp;countrylist.) in (USA UK ENG) %then %do;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is to:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. &amp;amp;country may only be ONE of the value USA, UK, ENG. For example: country = USA UK is invalid since it is two values, it may only be one. Country = USA is valid. Country = GER is invalid.&amp;nbsp;&lt;BR /&gt;2. Countrylist is a "list" and may only contain USA, UK, ENG. For example: countrylist&amp;nbsp; = USA UK is valid. Countrylist = USA UK ENG is valid. Countrylist = USA GER is invalid. Countrylist = USA USA UK is valid although it is bad programming (or perhaps a misstake).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;and hope it is clear.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 14:08:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754335#M237857</guid>
      <dc:creator>SasStatistics</dc:creator>
      <dc:date>2021-07-15T14:08:30Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Validation - A list of values in another list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754339#M237860</link>
      <description>&lt;P&gt;So modify my version to do what you want.&lt;/P&gt;
&lt;P&gt;If you have trouble post your code so we can see how to help you.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 14:18:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754339#M237860</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-15T14:18:28Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Validation - A list of values in another list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754348#M237866</link>
      <description>&lt;P&gt;My try which I know is wrong, but I have trouble implementing the check for two conditions when one of the condition involves looping.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
/*Validation 1: &amp;amp;country may only be ONE of the value USA, UK, ENG.*/

/*Validation 2: Countrylist is a "list" and may only contain USA, UK, ENG. For example: countrylist  = USA UK is valid. 
Countrylist = USA UK ENG is valid. Countrylist = USA GER is invalid. 
Countrylist = USA USA UK is valid although it is bad programming (or perhaps a misstake).*/

/* These two validation conditions must both be fullfilled at the same time*/

%macro ValidateCountries(country, countrylist) /minoperator mindelimiter=' ';
	%if %upcase(&amp;amp;country.) in (USA UK ENG) 
		AND   /* Have trouble how to check that all the looping cases are true in an AND statement? */
			%do i=1 %to %sysfunc(countw(&amp;amp;countrylist.));
				%let next=%qscan(&amp;amp;countrylist.,&amp;amp;i,%str( ));
				%if (%qupcase(&amp;amp;next) in %qupcase(&amp;amp;countrylist)) %then %do;
	    	%end;

	%then %do;
		%local answer;
		%if &amp;amp;country. in &amp;amp;countrylist. %then %do; 
		  %let answer= 1; 
		%end; 
		%else %do;
		  %let answer= 0; 
		%end;
		&amp;amp;answer; 
	%end;


	%else %do; 
		%put Error: country should be one of: USA UK ENG. 
					countrylist may only contain some of USA UK ENG. ;
	%end; 	


%mend; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Jul 2021 14:38:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754348#M237866</guid>
      <dc:creator>SasStatistics</dc:creator>
      <dc:date>2021-07-15T14:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Validation - A list of values in another list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754349#M237867</link>
      <description>&lt;P&gt;When you are done compare to this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-SPOILER&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro ValidateCountries(country, countrylist) /minoperator mindelimiter=' ';
  %local answer i next list;
  %let list=%qupcase(USA UK ENG);
  %let answer=1;
  %if not (%qupcase(&amp;amp;country) in &amp;amp;list) %then %do;
    %let answer=0;
    %put ERROR: COUNTRY value "&amp;amp;country" is not in &amp;amp;=list;
  %end;
  %do i=1 %to %sysfunc(countw(&amp;amp;countrylist));
    %let next=%qscan(&amp;amp;countrylist,&amp;amp;i,%str( ));
    %if not (%qupcase(&amp;amp;next) in &amp;amp;list) %then %do;
       %let answer=0;
       %put ERROR: COUNTRYLIST value "&amp;amp;next" is not in &amp;amp;=list;
    %end;
  %end;
&amp;amp;answer
%mend; 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/LI-SPOILER&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;283   %put %ValidateCountries(uk,usa uk);
1
284   %put %validateCountries(usa uk ,france usa uk);
ERROR: COUNTRY value "usa uk" is not in LIST=USA UK ENG
ERROR: COUNTRYLIST value "france" is not in LIST=USA UK ENG
0
&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Jul 2021 14:38:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754349#M237867</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-15T14:38:43Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Validation - A list of values in another list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754350#M237868</link>
      <description>Problem is, both if conditions must fulfilled at the same time. This logic only looks at one at the time?</description>
      <pubDate>Thu, 15 Jul 2021 14:39:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754350#M237868</guid>
      <dc:creator>SasStatistics</dc:creator>
      <dc:date>2021-07-15T14:39:15Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Validation - A list of values in another list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754353#M237869</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/381436"&gt;@SasStatistics&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Problem is, both if conditions must fulfilled at the same time. This logic only looks at one at the time?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Sequential testing of each condition gets you to the same end result. If the countrylist is wrong, you get notified. If the country is not in the countrylist, you get notified.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 14:43:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754353#M237869</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-15T14:43:26Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Validation - A list of values in another list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754358#M237870</link>
      <description>&lt;P&gt;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:&amp;nbsp;&amp;nbsp;&lt;A href="https://github.com/sasutils/macros/blob/master/parmv.sas" target="_self"&gt;%parmv()&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then your test case becomes:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro myrealmacro
(country  /* Single country code */
,countrylist /* Space delimited list of country codes */
);
%local macro parmerr;
%let macro=&amp;amp;sysmacroname;
%parmv(country,_val=USA UK ENG)
%parmv(countrylist,_words=1,_val=USA UK ENG)
%if (&amp;amp;parmerr) %then %return;

%put Body of actual macro that uses &amp;amp;=COUNTRY and &amp;amp;=COUNTRYLIST goes here ;
%mend myrealmacro;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;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.
&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Jul 2021 15:01:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Validation-A-list-of-values-in-another-list-of-values/m-p/754358#M237870</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-15T15:01:04Z</dc:date>
    </item>
  </channel>
</rss>

