<?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: Contents of the IN operator as a SAS macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Contents-of-the-IN-operator-as-a-SAS-macro/m-p/269246#M53334</link>
    <description>&lt;P&gt;It sounds like you are turning an easy problem into a difficult one.&amp;nbsp; It's easy, assuming that you know how to turn your spreadsheet into a SAS data set containing a variable that holds facility numbers.&amp;nbsp; (If you don't know that part, you can get help with that too, but that would be a separate question.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The third paramter in your macro would be the name of the SAS data set holding facility numbers.&amp;nbsp; Then your IN operator would look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;in (select distinct FACILITYNO from &amp;amp;var3)&lt;/P&gt;</description>
    <pubDate>Mon, 09 May 2016 17:42:24 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-05-09T17:42:24Z</dc:date>
    <item>
      <title>Contents of the IN operator as a SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Contents-of-the-IN-operator-as-a-SAS-macro/m-p/269207#M53322</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;any way we can put the contents of an IN operator in a SAS macro.&amp;nbsp;I'm doing something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC SQL;&lt;BR /&gt; CREATE TABLE data1&amp;nbsp;AS&lt;BR /&gt; SELECT *&lt;BR /&gt; FROM&amp;nbsp;dataset t1&lt;BR /&gt; WHERE &amp;nbsp;t1.PAYTOCGVRNPI in ('1023027968','1750591632');&lt;BR /&gt;QUIT;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The thing is that I have to do many data pulls based on subsetting on the variable &lt;SPAN&gt;PAYTOCGVRNPI, which takes different values everytime. I'd like to put the content of teh IN operator in a macro, but I'm running into quoting issues.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Any idea on how I could proceed here?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks you!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 May 2016 16:27:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Contents-of-the-IN-operator-as-a-SAS-macro/m-p/269207#M53322</guid>
      <dc:creator>avbraga</dc:creator>
      <dc:date>2016-05-09T16:27:22Z</dc:date>
    </item>
    <item>
      <title>Re: Contents of the IN operator as a SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Contents-of-the-IN-operator-as-a-SAS-macro/m-p/269212#M53323</link>
      <description>&lt;P&gt;Describe how your are setting your macro variable(s)&amp;nbsp;for use in the in statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You example code would work with: (though the comma isn't needed)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let Mvar = '1023027968','1750591632';

PROC SQL;
   CREATE TABLE data1 AS
   SELECT *
   FROM dataset t1
   WHERE  t1.PAYTOCGVRNPI in (&amp;amp;mvar);
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Are you passing values to a macro as parameters, generating them from a data set or something else?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 May 2016 16:39:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Contents-of-the-IN-operator-as-a-SAS-macro/m-p/269212#M53323</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-05-09T16:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: Contents of the IN operator as a SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Contents-of-the-IN-operator-as-a-SAS-macro/m-p/269214#M53325</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How are you creating your macro variables? If its from a different table use the quote function to help get quotes in the data. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you do all at once, do you really need to create multiple subsets of data?&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(paytocgvrnpi) into :select_list separated by " "
from my_table
where &amp;lt;your where condition&amp;gt;;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 May 2016 16:45:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Contents-of-the-IN-operator-as-a-SAS-macro/m-p/269214#M53325</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-05-09T16:45:12Z</dc:date>
    </item>
    <item>
      <title>Re: Contents of the IN operator as a SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Contents-of-the-IN-operator-as-a-SAS-macro/m-p/269226#M53328</link>
      <description>&lt;P&gt;Thx Ballard. I've tried this option, but I would like to put it in this format&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro a (var1, var2, var3);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;code....&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%mend a;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where:&lt;/P&gt;
&lt;P&gt;var1 &amp;nbsp;= would change the name of the datasets being created.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;var2 &amp;nbsp;= would be the variable I described previously to you&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;var3 &amp;nbsp;= would be a facility number&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;but again, when I do it this way the commas and the quoting becomes an issue.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;and I have a list of these paytocgrvnpi codes on a excel file for each facility number.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks for the assistance.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 May 2016 17:01:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Contents-of-the-IN-operator-as-a-SAS-macro/m-p/269226#M53328</guid>
      <dc:creator>avbraga</dc:creator>
      <dc:date>2016-05-09T17:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: Contents of the IN operator as a SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Contents-of-the-IN-operator-as-a-SAS-macro/m-p/269243#M53333</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/2685"&gt;@avbraga&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Thx Ballard. I've tried this option, but I would like to put it in this format&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;but again, when I do it this way the commas and the quoting becomes an issue.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The commas are &lt;STRONG&gt;not&lt;/STRONG&gt; needed unless you are still running SAS 9.0 (I think, don't remember exactly which releast but is quite awhile ago).&lt;/P&gt;
&lt;P&gt;So don't include them. Or if you need the commas at some other stage make a separate variable with commas inside the macro.&lt;/P&gt;
&lt;P&gt;And are you &lt;U&gt;&lt;EM&gt;&lt;STRONG&gt;always&lt;/STRONG&gt;&lt;/EM&gt;&lt;/U&gt; using character values that need to be quoted or will you sometimes need to pass actual numeric values?&lt;/P&gt;</description>
      <pubDate>Mon, 09 May 2016 17:35:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Contents-of-the-IN-operator-as-a-SAS-macro/m-p/269243#M53333</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-05-09T17:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: Contents of the IN operator as a SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Contents-of-the-IN-operator-as-a-SAS-macro/m-p/269246#M53334</link>
      <description>&lt;P&gt;It sounds like you are turning an easy problem into a difficult one.&amp;nbsp; It's easy, assuming that you know how to turn your spreadsheet into a SAS data set containing a variable that holds facility numbers.&amp;nbsp; (If you don't know that part, you can get help with that too, but that would be a separate question.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The third paramter in your macro would be the name of the SAS data set holding facility numbers.&amp;nbsp; Then your IN operator would look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;in (select distinct FACILITYNO from &amp;amp;var3)&lt;/P&gt;</description>
      <pubDate>Mon, 09 May 2016 17:42:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Contents-of-the-IN-operator-as-a-SAS-macro/m-p/269246#M53334</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-05-09T17:42:24Z</dc:date>
    </item>
    <item>
      <title>Re: Contents of the IN operator as a SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Contents-of-the-IN-operator-as-a-SAS-macro/m-p/269260#M53336</link>
      <description>&lt;P&gt;oh, this is interesting. a subquery within the query itself. Will try this approach. Thanks, Astounding.&lt;/P&gt;</description>
      <pubDate>Mon, 09 May 2016 18:37:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Contents-of-the-IN-operator-as-a-SAS-macro/m-p/269260#M53336</guid>
      <dc:creator>avbraga</dc:creator>
      <dc:date>2016-05-09T18:37:54Z</dc:date>
    </item>
  </channel>
</rss>

