<?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 with %IF (...) IN (...) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/MACRO-with-IF-IN/m-p/411728#M100672</link>
    <description>&lt;P&gt;I work with SAS 9.3 TS Level 1M1 W32_7PRO&lt;/P&gt;</description>
    <pubDate>Wed, 08 Nov 2017 22:02:23 GMT</pubDate>
    <dc:creator>x2PSx</dc:creator>
    <dc:date>2017-11-08T22:02:23Z</dc:date>
    <item>
      <title>MACRO with %IF (...) IN (...)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MACRO-with-IF-IN/m-p/411670#M100640</link>
      <description>&lt;P&gt;Hello, my macro doesn't work the way I want to. So basically this below works perfectly:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%MACRO mymacro() ;&lt;BR /&gt;%IF %substr(&amp;amp;n50prc0_aaaamm.,5,2) = 06&lt;BR /&gt;%THEN %DO;&lt;BR /&gt;[...]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However I would need something like this because I want every trimester to work&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%MACRO&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;mymacro&lt;/SPAN&gt;&lt;SPAN&gt;() ;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;%IF %substr(&amp;amp;n50prc0_aaaamm.,5,2) in (03,06,09,12)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;%THEN %DO;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[...]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried many different things including different options like MINDELIMITER but nothing seems to work for me. Thank you for your help&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 20:08:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MACRO-with-IF-IN/m-p/411670#M100640</guid>
      <dc:creator>x2PSx</dc:creator>
      <dc:date>2017-11-08T20:08:05Z</dc:date>
    </item>
    <item>
      <title>Re: MACRO with %IF (...) IN (...)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MACRO-with-IF-IN/m-p/411672#M100641</link>
      <description>&lt;P&gt;Are you using the "MINOPERATOR" option?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 20:14:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MACRO-with-IF-IN/m-p/411672#M100641</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-11-08T20:14:18Z</dc:date>
    </item>
    <item>
      <title>Re: MACRO with %IF (...) IN (...)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MACRO-with-IF-IN/m-p/411674#M100642</link>
      <description>&lt;P&gt;Yes, with this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;options MINOPERATOR;&lt;BR /&gt;%MACRO mymacro / MINDELIMITER=",";&lt;BR /&gt;%IF %substr(&amp;amp;n50prc0_aaaamm.,5,2) in (03,06,09,12)&lt;BR /&gt;%THEN %DO;&lt;BR /&gt;[...]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get this error:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;ERROR 13-12: Unrecognized SAS option name, MINOPERATOR.&lt;/P&gt;&lt;P&gt;2 %MACRO RAPPEL_PROD / MINDELIMITER=",";&lt;BR /&gt;ERROR: Extraneous information on %MACRO statement ignored.&lt;BR /&gt;ERROR: A dummy macro will be compiled.&lt;BR /&gt;3&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 20:19:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MACRO-with-IF-IN/m-p/411674#M100642</guid>
      <dc:creator>x2PSx</dc:creator>
      <dc:date>2017-11-08T20:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: MACRO with %IF (...) IN (...)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MACRO-with-IF-IN/m-p/411677#M100644</link>
      <description>&lt;P&gt;Macro language does support an IN operator.&amp;nbsp; As &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/93752"&gt;@collinelliot&lt;/a&gt;&amp;nbsp;indicated, you need two options properly set, plus the matching syntax in your code.&amp;nbsp; Tedious, but it is possible.&amp;nbsp; (For example, get rid of the parentheses around the list of values.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An easy workaround for this case might (depending on the range of values) be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let two_digits = %substr(&amp;amp;n50prc0_aaaamm.,5,2);&lt;/P&gt;
&lt;P&gt;%if &amp;amp;two_digits = &amp;amp;two_digits / 3 * 3 %then %do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This statement would apply integer arithmetic (truncating remainders).&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 20:24:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MACRO-with-IF-IN/m-p/411677#M100644</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-11-08T20:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: MACRO with %IF (...) IN (...)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MACRO-with-IF-IN/m-p/411682#M100648</link>
      <description>&lt;P&gt;What version of SAS are you using?&lt;/P&gt;
&lt;PRE&gt;791  %put &amp;amp;sysver ;
9.4&lt;/PRE&gt;
&lt;P&gt;You could use a little arithmetic.&amp;nbsp; Try this little test.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test;
  %do m=1 %to 12 ;
    %let mm=%sysfunc(putn(&amp;amp;m,z2));
    %let mod4=%sysfunc(mod(&amp;amp;mm,4));
    %put &amp;amp;=m &amp;amp;=mm &amp;amp;=mod4 ;
    %if not %sysfunc(mod(&amp;amp;mm,4)) %then %put Found end of quarter ;
  %end;
%mend ;
%test;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 20:32:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MACRO-with-IF-IN/m-p/411682#M100648</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-11-08T20:32:48Z</dc:date>
    </item>
    <item>
      <title>Re: MACRO with %IF (...) IN (...)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MACRO-with-IF-IN/m-p/411712#M100660</link>
      <description>&lt;P&gt;You need&amp;nbsp; single quotes in the MINDELIMITER&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This works for me:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO myMacro(n50prc0_aaaamm=) / mindelimiter=',' minoperator ;
%IF %substr(&amp;amp;n50prc0_aaaamm.,5,2) in (03,06,09,12)
%THEN %DO;

%PUT &amp;amp;n50prc0_aaaamm. -&amp;gt; MATCH;

%END;
%ELSE %DO;
%PUT &amp;amp;n50prc0_aaaamm. -&amp;gt; NO MATCH;

%END;

%MEND myMacro;

%mymacro(n50prc0_aaaamm=199501);
%mymacro(n50prc0_aaaamm=199502);
%mymacro(n50prc0_aaaamm=199503);
%mymacro(n50prc0_aaaamm=199504);
%mymacro(n50prc0_aaaamm=199505);
%mymacro(n50prc0_aaaamm=199506);
%mymacro(n50prc0_aaaamm=199509);
%mymacro(n50prc0_aaaamm=199512);
%mymacro(n50prc0_aaaamm=199513);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Nov 2017 21:39:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MACRO-with-IF-IN/m-p/411712#M100660</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-08T21:39:19Z</dc:date>
    </item>
    <item>
      <title>Re: MACRO with %IF (...) IN (...)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MACRO-with-IF-IN/m-p/411721#M100666</link>
      <description>&lt;P&gt;thank you, but it doesn't for me. I should mention that I run this SAS code via a secure shell. My first code does work though, but I don't think the options are recognized&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 21:51:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MACRO-with-IF-IN/m-p/411721#M100666</guid>
      <dc:creator>x2PSx</dc:creator>
      <dc:date>2017-11-08T21:51:52Z</dc:date>
    </item>
    <item>
      <title>Re: MACRO with %IF (...) IN (...)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MACRO-with-IF-IN/m-p/411722#M100667</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/150111"&gt;@x2PSx&lt;/a&gt;&amp;nbsp;then likely Tom has the correct idea, you're working on an older version of SAS that doesn't support MINDELIMITER - which would be pretty old. Did you verify the SAS version? Or are you using WPS? That doesn't work the same either.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 21:56:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MACRO-with-IF-IN/m-p/411722#M100667</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-08T21:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: MACRO with %IF (...) IN (...)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MACRO-with-IF-IN/m-p/411724#M100669</link>
      <description>&lt;P&gt;That is a very nice shortcut indeed for my specific problem, thank you&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 22:00:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MACRO-with-IF-IN/m-p/411724#M100669</guid>
      <dc:creator>x2PSx</dc:creator>
      <dc:date>2017-11-08T22:00:57Z</dc:date>
    </item>
    <item>
      <title>Re: MACRO with %IF (...) IN (...)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MACRO-with-IF-IN/m-p/411728#M100672</link>
      <description>&lt;P&gt;I work with SAS 9.3 TS Level 1M1 W32_7PRO&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 22:02:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MACRO-with-IF-IN/m-p/411728#M100672</guid>
      <dc:creator>x2PSx</dc:creator>
      <dc:date>2017-11-08T22:02:23Z</dc:date>
    </item>
    <item>
      <title>Re: MACRO with %IF (...) IN (...)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MACRO-with-IF-IN/m-p/411739#M100673</link>
      <description>&lt;P&gt;MINDELIMITER has been available as of SAS 9.2+&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 22:45:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MACRO-with-IF-IN/m-p/411739#M100673</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-08T22:45:43Z</dc:date>
    </item>
  </channel>
</rss>

