<?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: Macros with conditions in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Macros-with-conditions/m-p/183737#M46738</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a million, that worked! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Oct 2014 10:57:38 GMT</pubDate>
    <dc:creator>brophymj</dc:creator>
    <dc:date>2014-10-15T10:57:38Z</dc:date>
    <item>
      <title>Macros with conditions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macros-with-conditions/m-p/183735#M46736</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;I have a data set with a field called Key which has values ranging from 1 to 25 and these represent different conditions;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Condition one is: if Fieldx = 1 then let comment = "exclud"e&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Condition two is: if Fieldx = 2 and Fieldy ne 4 then comment =" always include"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and so on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the conditions vary in terms of the number of fields that affect the condition&lt;/P&gt;&lt;P&gt;I want to build a macro like;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro test(condition);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;set test;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if &amp;amp;condition;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%test(fieldx=2);&lt;/P&gt;&lt;P&gt;%test(fieldx=2 and fieldy ne 4);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Something like this but which works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically I can do this very simply if there is only one field affecting the condition but if it varies is there a way of building this into the macro&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Oct 2014 10:15:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macros-with-conditions/m-p/183735#M46736</guid>
      <dc:creator>brophymj</dc:creator>
      <dc:date>2014-10-14T10:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: Macros with conditions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macros-with-conditions/m-p/183736#M46737</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have you tried to use the function %STR()? All macro should work if you call it like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%test(%STR(fieldx=2));&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%test(%STR(fieldx=2 and fieldy ne 4));&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Oct 2014 10:40:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macros-with-conditions/m-p/183736#M46737</guid>
      <dc:creator>arodriguez</dc:creator>
      <dc:date>2014-10-15T10:40:17Z</dc:date>
    </item>
    <item>
      <title>Re: Macros with conditions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macros-with-conditions/m-p/183737#M46738</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a million, that worked! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Oct 2014 10:57:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macros-with-conditions/m-p/183737#M46738</guid>
      <dc:creator>brophymj</dc:creator>
      <dc:date>2014-10-15T10:57:38Z</dc:date>
    </item>
  </channel>
</rss>

