<?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 How to select all in a SAS Macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-all-in-a-SAS-Macro/m-p/101481#M21250</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a SAS Macro that looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%LET SUBGRP=('202')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and I'm using it in a proc SQL statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cm.subgrp in @SUBGRP&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works, but what if I want to allow the user of the program to select all subgroups?&amp;nbsp; Sometimes they will need to do that.&amp;nbsp; How would I adjust my macro?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried:&lt;/P&gt;&lt;P&gt;%LET SUBGRP=('*')&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;%LET SUBGRP=('%')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;..and both of those didn't work.&amp;nbsp; Any suggestions?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 02 Oct 2013 16:37:32 GMT</pubDate>
    <dc:creator>teg_76</dc:creator>
    <dc:date>2013-10-02T16:37:32Z</dc:date>
    <item>
      <title>How to select all in a SAS Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-all-in-a-SAS-Macro/m-p/101481#M21250</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a SAS Macro that looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%LET SUBGRP=('202')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and I'm using it in a proc SQL statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cm.subgrp in @SUBGRP&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works, but what if I want to allow the user of the program to select all subgroups?&amp;nbsp; Sometimes they will need to do that.&amp;nbsp; How would I adjust my macro?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried:&lt;/P&gt;&lt;P&gt;%LET SUBGRP=('*')&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;%LET SUBGRP=('%')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;..and both of those didn't work.&amp;nbsp; Any suggestions?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Oct 2013 16:37:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-all-in-a-SAS-Macro/m-p/101481#M21250</guid>
      <dc:creator>teg_76</dc:creator>
      <dc:date>2013-10-02T16:37:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to select all in a SAS Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-all-in-a-SAS-Macro/m-p/101482#M21251</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not really possible in PROC SQL to use both the IN operator and some type of wildcard.&lt;/P&gt;&lt;P&gt;If you are actually inside of a macro so that you can use macro logic then you could conditionally generate different SQL based on the value of your macro variable.&amp;nbsp; For example if you decide to use %let subgrp=*; to mean select all then you could code it like this:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; background-color: #ffffff;"&gt;... &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; background-color: #ffffff;"&gt;where &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%if "&amp;amp;subgrp" = "*" then 1 ; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%else &lt;SPAN style="font-family: 'courier new', courier; background-color: #ffffff;"&gt;cm.subgrp in&lt;/SPAN&gt; &amp;amp;subgrp ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Otherwise you could place the whole conditional into the macro variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let subgrp=1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;or&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let subgrp=cm.subgrp in ('22','33');&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; background-color: #ffffff;"&gt;... &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; background-color: #ffffff;"&gt;where &lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;amp;subgrp&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Oct 2013 17:46:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-all-in-a-SAS-Macro/m-p/101482#M21251</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-10-02T17:46:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to select all in a SAS Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-all-in-a-SAS-Macro/m-p/101483#M21252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your help Tom!&amp;nbsp; I'll use your suggestions and see if I can work around the problem...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Oct 2013 22:31:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-all-in-a-SAS-Macro/m-p/101483#M21252</guid>
      <dc:creator>teg_76</dc:creator>
      <dc:date>2013-10-02T22:31:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to select all in a SAS Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-all-in-a-SAS-Macro/m-p/101484#M21253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could also update the proc SQL with something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%LET SUBGRP = ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc sql;&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%IF &amp;amp;SUBGRP ne %str() %THEN %DO;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; where cm.subgrp in @SUBGRP&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ...&lt;/P&gt;&lt;P&gt;%END; %ELSE %DO;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ....&lt;/P&gt;&lt;P&gt;%END;&lt;/P&gt;&lt;P&gt;...;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This would check whether a value was assigned to your macro and, in such a case, add the where condition to your sql query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Florent&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Oct 2013 14:43:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-all-in-a-SAS-Macro/m-p/101484#M21253</guid>
      <dc:creator>Florent</dc:creator>
      <dc:date>2013-10-08T14:43:20Z</dc:date>
    </item>
  </channel>
</rss>

