<?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 sample macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/sample-macro/m-p/86077#M18484</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am new to macro. Is the macro below valid? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro SASrules;&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data DS2;&lt;/P&gt;&lt;P&gt;set DS1;&lt;/P&gt;&lt;P&gt;a = sqrt(b);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if (a &amp;gt; 3) then&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 25 Jan 2013 15:14:11 GMT</pubDate>
    <dc:creator>uday</dc:creator>
    <dc:date>2013-01-25T15:14:11Z</dc:date>
    <item>
      <title>sample macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sample-macro/m-p/86077#M18484</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am new to macro. Is the macro below valid? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro SASrules;&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data DS2;&lt;/P&gt;&lt;P&gt;set DS1;&lt;/P&gt;&lt;P&gt;a = sqrt(b);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if (a &amp;gt; 3) then&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Jan 2013 15:14:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sample-macro/m-p/86077#M18484</guid>
      <dc:creator>uday</dc:creator>
      <dc:date>2013-01-25T15:14:11Z</dc:date>
    </item>
    <item>
      <title>Re: sample macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sample-macro/m-p/86078#M18485</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro SASrules;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;else&amp;nbsp; /*this needs a preceding IF statement, you can't have an ELSE just hanging around*/&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run; /* this is out of place...."ELSE;RUN;....should be more like ELSE; &amp;lt;statement to be performed&amp;gt;; RUN;*/&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*this could be ok, but you need to have a MACRO variable...maybe the 'b', or the '3'....*/&lt;/P&gt;&lt;P&gt;/* something like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data DS2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set DS1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a = sqrt(&amp;amp;macro_var.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if a &amp;gt; 3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;*/&lt;/P&gt;&lt;P&gt;data DS2;&lt;/P&gt;&lt;P&gt;set DS1;&lt;/P&gt;&lt;P&gt;a = sqrt(b);&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; if (a &amp;gt; 3) then..../*then what?*/&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Jan 2013 15:23:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sample-macro/m-p/86078#M18485</guid>
      <dc:creator>AncaTilea</dc:creator>
      <dc:date>2013-01-25T15:23:21Z</dc:date>
    </item>
    <item>
      <title>Re: sample macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sample-macro/m-p/86079#M18486</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The important thing to consider when using SAS macros is that they are program code generators. Your example would generate the text you provide into a program calling the macro. However as Anca tilea mentioned the place in your code where you call should have an IF statement, within a data step, before the Else or the generated code will cause errors. Also your Else statment is not properly ended (Run is not an executeable statement).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Jan 2013 15:46:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sample-macro/m-p/86079#M18486</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2013-01-25T15:46:50Z</dc:date>
    </item>
    <item>
      <title>Re: sample macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sample-macro/m-p/86080#M18487</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you so much!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Jan 2013 15:53:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sample-macro/m-p/86080#M18487</guid>
      <dc:creator>uday</dc:creator>
      <dc:date>2013-01-25T15:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: sample macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sample-macro/m-p/86081#M18488</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In addtion to the comments above, I wonder why you have created this macro at all. It contains no macro statements, so you could simply place the interior of the macro into the appropriate part of the larger program. So even if the code were correct, the macro serves no purpose whatsoever. It is a waste of time to turn this particular code into a macro.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Normally, when you want to write a macro, you have a situation where you will want the macro output to vary given certain conditions, and/or certain input values. For example, here is a small macro that checks to see if a SAS data set exists and performs certain actions depending on whether or not the SAS data set exists.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro check;&lt;/P&gt;&lt;P&gt;%if %sysfunc(exist(work.mydata)) %then a=sqrt(b)%str(;);&lt;/P&gt;&lt;P&gt;%else a=b%str(;);&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Jan 2013 16:08:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sample-macro/m-p/86081#M18488</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2013-01-25T16:08:11Z</dc:date>
    </item>
  </channel>
</rss>

