<?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: multiple Macro values issue - better way to apply filter on these values on a dataset in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/multiple-Macro-values-issue-better-way-to-apply-filter-on-these/m-p/546687#M8248</link>
    <description>&lt;P&gt;Looks overly complicated, it shouldn't matter if the second argument has a value or not.&lt;/P&gt;
&lt;P&gt;You could make it a little more robust.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro addcommas2(somevars,addmore);
%if %length(&amp;amp;somevars.&amp;amp;addmore) %then
%sysfunc(tranwrd(%qsysfunc(compbl(&amp;amp;somevars &amp;amp;addmore)),%str( ),%str(,)));
%mend; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;110   %put %addcommas(x y,z);
x,y,z
111   %put %addcommas2(x y,z);
x,y,z
112   %put %addcommas(x y,);
x,y
113   %put %addcommas2(x y,);
x,y
114   %put %addcommas();
WARNING: Argument 1 to function TRANSLATE referenced by the %SYSFUNC or %QSYSFUNC macro function is out of
         range.

115   %put %addcommas2();

116   %put %addcommas(x   y,z);
x,,,y,z
117   %put %addcommas2(x   y,z);
x,y,z
&lt;/PRE&gt;</description>
    <pubDate>Wed, 27 Mar 2019 20:44:46 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-03-27T20:44:46Z</dc:date>
    <item>
      <title>multiple Macro values issue - better way to apply filter on these values on a dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/multiple-Macro-values-issue-better-way-to-apply-filter-on-these/m-p/546338#M8209</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a macro variable which has multiple values in it separated by a ',' . I want to use these macro variable values to filter records from a dataset, can u please suggest a better way to do it, I understand we can use array loop to do this but is there any other ways in which it can be implemented?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Sample code:&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Data abc;&lt;/P&gt;&lt;P&gt;input month$ sales;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;jan 20&lt;/P&gt;&lt;P&gt;feb 50&lt;/P&gt;&lt;P&gt;feb 60&lt;/P&gt;&lt;P&gt;mar 60&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Macro variable 'mon' has multiple values separated by a ','&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;%let mon = jan, feb;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I want to filter records in &lt;STRONG&gt;dataset abc&lt;/STRONG&gt; by applying these macro values, the below case might error and I'm looking for better way to implement this step, so my final output should have only the records that matches for jan and feb months&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data b;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set abc;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;where month in &amp;amp;mon.;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;expected output :&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;month sales&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;jan 20&lt;/P&gt;&lt;P&gt;feb 50&lt;/P&gt;&lt;P&gt;feb 60&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2019 22:49:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/multiple-Macro-values-issue-better-way-to-apply-filter-on-these/m-p/546338#M8209</guid>
      <dc:creator>Kirtid</dc:creator>
      <dc:date>2019-03-26T22:49:03Z</dc:date>
    </item>
    <item>
      <title>Re: multiple Macro values issue - better way to apply filter on these values on a dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/multiple-Macro-values-issue-better-way-to-apply-filter-on-these/m-p/546339#M8210</link>
      <description>&lt;P&gt;How is that macro variable created? As shown it's problematic because no quotes, but depending on how you're creating it there are ways to work around that or add it in.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/238772"&gt;@Kirtid&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a macro variable which has multiple values in it separated by a ',' . I want to use these macro variable values to filter records from a dataset, can u please suggest a better way to do it, I understand we can use array loop to do this but is there any other ways in which it can be implemented?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Sample code:&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Data abc;&lt;/P&gt;
&lt;P&gt;input month$ sales;&lt;/P&gt;
&lt;P&gt;cards;&lt;/P&gt;
&lt;P&gt;jan 20&lt;/P&gt;
&lt;P&gt;feb 50&lt;/P&gt;
&lt;P&gt;feb 60&lt;/P&gt;
&lt;P&gt;mar 60&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Macro variable 'mon' has multiple values separated by a ','&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;%let mon = jan, feb;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now I want to filter records in &lt;STRONG&gt;dataset abc&lt;/STRONG&gt; by applying these macro values, the below case might error and I'm looking for better way to implement this step, so my final output should have only the records that matches for jan and feb months&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data b;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;set abc;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;where month in &amp;amp;mon.;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;expected output :&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;month sales&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;jan 20&lt;/P&gt;
&lt;P&gt;feb 50&lt;/P&gt;
&lt;P&gt;feb 60&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2019 22:50:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/multiple-Macro-values-issue-better-way-to-apply-filter-on-these/m-p/546339#M8210</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-03-26T22:50:52Z</dc:date>
    </item>
    <item>
      <title>Re: multiple Macro values issue - better way to apply filter on these values on a dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/multiple-Macro-values-issue-better-way-to-apply-filter-on-these/m-p/546345#M8211</link>
      <description>&lt;P&gt;Thanks for your reply Reeza. The macro values are created from another dataset from where we get the unique month information. Would it work by having single quotes around the values? - something like this : %let mon = 'jan','feb';&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2019 22:58:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/multiple-Macro-values-issue-better-way-to-apply-filter-on-these/m-p/546345#M8211</guid>
      <dc:creator>Kirtid</dc:creator>
      <dc:date>2019-03-26T22:58:55Z</dc:date>
    </item>
    <item>
      <title>Re: multiple Macro values issue - better way to apply filter on these values on a dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/multiple-Macro-values-issue-better-way-to-apply-filter-on-these/m-p/546346#M8212</link>
      <description>&lt;P&gt;Why did you place the comma in the first place?&lt;/P&gt;
&lt;P&gt;And the syntax for using IN requires the values to be within ( ) and character values have to be in quotes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;data want;
   set sashelp.class;
   where name in ('John' 'Alice' 'James' 'Philip');
run;&lt;/PRE&gt;
&lt;P&gt;When the IN operator was first introduced to SAS it did require a comma delimited list but that has been gone for quite awhile.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As long as your case of the values in you data set matches I would expect this to work.&lt;/P&gt;
&lt;PRE&gt;%let mon = 'jan'  'feb';
Data abc;
input month$ sales;
cards;
jan 20
feb 50
feb 60
mar 60
;
run;
data b;
   set abc;
   where month in ( &amp;amp;mon.); 
run;
&lt;/PRE&gt;
&lt;P&gt;If you case is not consistent such as values like Jan and jan both appearing you'll need to address that. Hint: function UPCASE may help.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2019 23:01:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/multiple-Macro-values-issue-better-way-to-apply-filter-on-these/m-p/546346#M8212</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-03-26T23:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: multiple Macro values issue - better way to apply filter on these values on a dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/multiple-Macro-values-issue-better-way-to-apply-filter-on-these/m-p/546348#M8213</link>
      <description>&lt;P&gt;Thanks for your reply.. hmm, but the problem is that the macro values are separated by a comma as these values are to be be used for different other purposes, so I may not be able to adjust or edit the way they appear and I just brought this month only as a sample case.&lt;/P&gt;&lt;P&gt;if my macro values are still appearing with comma separation, how can we still make it work ?&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2019 23:11:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/multiple-Macro-values-issue-better-way-to-apply-filter-on-these/m-p/546348#M8213</guid>
      <dc:creator>Kirtid</dc:creator>
      <dc:date>2019-03-26T23:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: multiple Macro values issue - better way to apply filter on these values on a dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/multiple-Macro-values-issue-better-way-to-apply-filter-on-these/m-p/546350#M8214</link>
      <description>&lt;P&gt;Your original problem was just the lack of () around the list.&amp;nbsp;&amp;nbsp;If the values are space delimited then combining two lists is easy.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where x in (&amp;amp;list1 &amp;amp;list2)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the values have commas then combing two lists is a pain.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let list1=a,b;
%let list2=;
%let full_list=&amp;amp;list1;
%if %length(&amp;amp;list2) %then %let full_list=&amp;amp;full_list,&amp;amp;list2;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I find it is usually better to add in the commas when they are needed.&amp;nbsp; SQL syntax is where it is normally needed.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let varlist=id date ;
....
by &amp;amp;varlist;
....
%let varlistc=%sysfunc(tranwrd(%sysfunc(compbl(&amp;amp;varlist)),%str( ),%str(,)));
....
order by &amp;amp;varlistc
....
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2019 23:21:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/multiple-Macro-values-issue-better-way-to-apply-filter-on-these/m-p/546350#M8214</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-03-26T23:21:43Z</dc:date>
    </item>
    <item>
      <title>Re: multiple Macro values issue - better way to apply filter on these values on a dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/multiple-Macro-values-issue-better-way-to-apply-filter-on-these/m-p/546362#M8219</link>
      <description>&lt;P&gt;You can use your macro variable as is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   where findw("&amp;amp;mon.", strip(month)) &amp;gt; 0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without testing, I'm not sure whether the STRIP function is actually needed here.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2019 02:07:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/multiple-Macro-values-issue-better-way-to-apply-filter-on-these/m-p/546362#M8219</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-03-27T02:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: multiple Macro values issue - better way to apply filter on these values on a dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/multiple-Macro-values-issue-better-way-to-apply-filter-on-these/m-p/546398#M8222</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/238772"&gt;@Kirtid&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for your reply.. hmm, but the problem is that the macro values are separated by a comma as these values are to be be used for different other purposes, so I may not be able to adjust or edit the way they appear and I just brought this month only as a sample case.&lt;/P&gt;
&lt;P&gt;if my macro values are still appearing with comma separation, how can we still make it work ?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Use an intermediate data step to convert your macro variable to a text you can use in an in-list:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data abc;
input month$ sales;
cards;
jan 20
feb 50
feb 60
mar 60
;
run;

%let mon = jan, feb;

data _null_;
length target $1000;
source = "&amp;amp;mon.";
do i = 1 to countw(source,',');
  target = catx(',',target,quote(strip(scan(source,i,','))));
end;
call symputx('new_mon',target);
run;

data b;
set abc;
where month in (&amp;amp;new_mon.); 
run;

proc print data=b noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;month    sales

 jan       20 
 feb       50 
 feb       60 
&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Mar 2019 07:55:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/multiple-Macro-values-issue-better-way-to-apply-filter-on-these/m-p/546398#M8222</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-03-27T07:55:24Z</dc:date>
    </item>
    <item>
      <title>Re: multiple Macro values issue - better way to apply filter on these values on a dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/multiple-Macro-values-issue-better-way-to-apply-filter-on-these/m-p/546580#M8233</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/238772"&gt;@Kirtid&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for your reply Reeza. The macro values are created from another dataset from where we get the unique month information. Would it work by having single quotes around the values? - something like this : %let mon = 'jan','feb';&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, change your macro variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can create your list from SQL using the following which creates a quoted list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select quote(name) into :name_list separated by " "
from sashelp.class;
quit;

%put &amp;amp;name_list.;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or you can just use the data directly from the data set, assuming it's called sublist, as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table subset as
select *
from sashelp.class
where name in (select name from &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;sublist&lt;/STRONG&gt;&lt;/FONT&gt;);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Mar 2019 16:14:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/multiple-Macro-values-issue-better-way-to-apply-filter-on-these/m-p/546580#M8233</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-03-27T16:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: multiple Macro values issue - better way to apply filter on these values on a dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/multiple-Macro-values-issue-better-way-to-apply-filter-on-these/m-p/546678#M8247</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/238772"&gt;@Kirtid&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for your reply.. hmm, but the problem is that the macro values are separated by a comma as these values are to be be used for different other purposes, so I may not be able to adjust or edit the way they appear and I just brought this month only as a sample case.&lt;/P&gt;
&lt;P&gt;if my macro values are still appearing with comma separation, how can we still make it work ?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Since passing values with commas is a headache requiring macro quoting and such I use a utility macro to add commas to list of things when needed. I don't remember where I found this:&lt;/P&gt;
&lt;PRE&gt;%macro addcommas(somevars,addmore);
%if %sysevalf(%superq(addmore)=,boolean) %then %let commavalue=%sysfunc(translate(&amp;amp;somevars, %str(,), %str( ) )) ; 
%else %let commavalue=%sysfunc(translate(&amp;amp;somevars &amp;amp;addmore, %str(,), %str( ) ));
&amp;amp;commavalue

%mend; &lt;/PRE&gt;
&lt;P&gt;This can either be used to assign values to a variable such as:&lt;/P&gt;
&lt;PRE&gt;%let varlist= jan feb mar stupid;
%let other = pdq;
%let varlist2 = %addcommas(&amp;amp;varlist.,&amp;amp;other.)    ;

%put &amp;amp;varlist2.;&lt;/PRE&gt;
&lt;P&gt;or directly in the code that needs the list&lt;/P&gt;
&lt;PRE&gt;%let varlist= name sex age;

proc sql;
   select %addcommas(&amp;amp;varlist.)
   from sashelp.class
   ;
quit;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Mar 2019 20:30:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/multiple-Macro-values-issue-better-way-to-apply-filter-on-these/m-p/546678#M8247</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-03-27T20:30:24Z</dc:date>
    </item>
    <item>
      <title>Re: multiple Macro values issue - better way to apply filter on these values on a dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/multiple-Macro-values-issue-better-way-to-apply-filter-on-these/m-p/546687#M8248</link>
      <description>&lt;P&gt;Looks overly complicated, it shouldn't matter if the second argument has a value or not.&lt;/P&gt;
&lt;P&gt;You could make it a little more robust.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro addcommas2(somevars,addmore);
%if %length(&amp;amp;somevars.&amp;amp;addmore) %then
%sysfunc(tranwrd(%qsysfunc(compbl(&amp;amp;somevars &amp;amp;addmore)),%str( ),%str(,)));
%mend; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;110   %put %addcommas(x y,z);
x,y,z
111   %put %addcommas2(x y,z);
x,y,z
112   %put %addcommas(x y,);
x,y
113   %put %addcommas2(x y,);
x,y
114   %put %addcommas();
WARNING: Argument 1 to function TRANSLATE referenced by the %SYSFUNC or %QSYSFUNC macro function is out of
         range.

115   %put %addcommas2();

116   %put %addcommas(x   y,z);
x,,,y,z
117   %put %addcommas2(x   y,z);
x,y,z
&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Mar 2019 20:44:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/multiple-Macro-values-issue-better-way-to-apply-filter-on-these/m-p/546687#M8248</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-03-27T20:44:46Z</dc:date>
    </item>
    <item>
      <title>Re: multiple Macro values issue - better way to apply filter on these values on a dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/multiple-Macro-values-issue-better-way-to-apply-filter-on-these/m-p/547436#M8378</link>
      <description>Thanks all for the giving me different views on this topic. Another approach I used tranwrd func&lt;BR /&gt;with cat . Month in strip(Cat ("'",tranwrd(&amp;amp;mon.,",","','"),"'"))</description>
      <pubDate>Sat, 30 Mar 2019 19:39:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/multiple-Macro-values-issue-better-way-to-apply-filter-on-these/m-p/547436#M8378</guid>
      <dc:creator>Kirtid</dc:creator>
      <dc:date>2019-03-30T19:39:02Z</dc:date>
    </item>
    <item>
      <title>Re: multiple Macro values issue - better way to apply filter on these values on a dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/multiple-Macro-values-issue-better-way-to-apply-filter-on-these/m-p/547456#M8385</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/238772"&gt;@Kirtid&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thanks all for the giving me different views on this topic. Another approach I used tranwrd func&lt;BR /&gt;with cat . Month in strip(Cat ("'",tranwrd(&amp;amp;mon.,",","','"),"'"))&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That does not look like valid code if the MON macro variable has multiple values, like JAN,FEB.&lt;/P&gt;
&lt;P&gt;I am not even sure you can use syntax like that.&amp;nbsp; Your expression is in the form:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;var in expression&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I am pretty sure that you can only use&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;var in (&amp;lt;list of values&amp;gt;)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want IN to check a list of variables then make an array.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array x var1 var2 ....;
...
if var in x;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 30 Mar 2019 23:21:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/multiple-Macro-values-issue-better-way-to-apply-filter-on-these/m-p/547456#M8385</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-03-30T23:21:53Z</dc:date>
    </item>
  </channel>
</rss>

