<?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 Storing a list of values in a macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Storing-a-list-of-values-in-a-macro-variable/m-p/275720#M55174</link>
    <description>&lt;P&gt;Typically, I run my program with only one value assigned to a macro variable as such:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let Client = 'BCBSFL';&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Client is later referenced as such:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
	select distinct NDC_Num format = $quote13. into :Specialty separated by ','
		from pcom1.TRIESSENT_FEE_SCHEDULE (where= (Clnt_CD = &lt;STRONG&gt;&amp;amp;Client&lt;/STRONG&gt;));
		run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I want my code to be more versatile to handle a list of values (all Clients) rather than a single value. Note: there are many places where the macro variable Client is referenced, so I'd prefer not to simply have an in list wherever Client is referenced.&lt;/P&gt;</description>
    <pubDate>Tue, 07 Jun 2016 15:55:08 GMT</pubDate>
    <dc:creator>JediApprentice</dc:creator>
    <dc:date>2016-06-07T15:55:08Z</dc:date>
    <item>
      <title>Storing a list of values in a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Storing-a-list-of-values-in-a-macro-variable/m-p/275720#M55174</link>
      <description>&lt;P&gt;Typically, I run my program with only one value assigned to a macro variable as such:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let Client = 'BCBSFL';&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Client is later referenced as such:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
	select distinct NDC_Num format = $quote13. into :Specialty separated by ','
		from pcom1.TRIESSENT_FEE_SCHEDULE (where= (Clnt_CD = &lt;STRONG&gt;&amp;amp;Client&lt;/STRONG&gt;));
		run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I want my code to be more versatile to handle a list of values (all Clients) rather than a single value. Note: there are many places where the macro variable Client is referenced, so I'd prefer not to simply have an in list wherever Client is referenced.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 15:55:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Storing-a-list-of-values-in-a-macro-variable/m-p/275720#M55174</guid>
      <dc:creator>JediApprentice</dc:creator>
      <dc:date>2016-06-07T15:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: Storing a list of values in a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Storing-a-list-of-values-in-a-macro-variable/m-p/275727#M55177</link>
      <description>&lt;P&gt;Personally my opinion is don't. &amp;nbsp;Datasets are there to keep "data" items. &amp;nbsp;For instance:&lt;/P&gt;
&lt;PRE&gt;data params;
  val="Acura"; output;
  val="Audi"; output;
run;
proc sql;
  create table WANT as
  select  *
  from    SASHELP.CARS
  where   MAKE in (select VAL from PARAMS);
quit;
  &lt;/PRE&gt;
&lt;P&gt;Your "list of data" is stored in a dataset, this is queried in the SQL clause as a subquery. &amp;nbsp;Simple Base SAS code, easy to maintain/understand and expand upon, and you can use all Base SAS processing on your parameters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 16:10:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Storing-a-list-of-values-in-a-macro-variable/m-p/275727#M55177</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-06-07T16:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: Storing a list of values in a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Storing-a-list-of-values-in-a-macro-variable/m-p/275731#M55179</link>
      <description>&lt;P&gt;If you don't want a "list" as used then perhaps a different variable that does contain the list of clients and then loop over them?&lt;/P&gt;
&lt;P&gt;Or a dataset with the client values and then use a Datastep and call execute to generate the code for each value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first might be easier to adapt to your code.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 16:14:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Storing-a-list-of-values-in-a-macro-variable/m-p/275731#M55179</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-06-07T16:14:36Z</dc:date>
    </item>
    <item>
      <title>Re: Storing a list of values in a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Storing-a-list-of-values-in-a-macro-variable/m-p/275732#M55180</link>
      <description>&lt;P&gt;Consider a slight change to your program, in the WHERE clause:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where = (Clnt_CD in (&amp;amp;client))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This works for either a single item or a list:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let Client = 'BCBSFL';&lt;/P&gt;
&lt;P&gt;%let Client = 'BCBSFL' 'BCBSNH';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that commas are not required.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The more difficult question is what else you want to do with &amp;amp;CLIENT.&amp;nbsp; How else will your program be using it.&amp;nbsp; You may need to learn a little more macro language to take a list of values and select one of them at a time.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 16:15:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Storing-a-list-of-values-in-a-macro-variable/m-p/275732#M55180</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-06-07T16:15:56Z</dc:date>
    </item>
    <item>
      <title>Re: Storing a list of values in a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Storing-a-list-of-values-in-a-macro-variable/m-p/275734#M55182</link>
      <description>&lt;P&gt;Thank you,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding﻿&lt;/a&gt;. My program is only using Client in where conditions like in my example, so no need to loop through the list, so this solution seems to be the simplest. Thank you all for your help! Much appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 16:21:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Storing-a-list-of-values-in-a-macro-variable/m-p/275734#M55182</guid>
      <dc:creator>JediApprentice</dc:creator>
      <dc:date>2016-06-07T16:21:43Z</dc:date>
    </item>
  </channel>
</rss>

